from random import randint
for i in range(10):
a=randint(1,10)
n=randint(1,10)
mm=a*n
ana=input("what is {} times{} ? ".format(a,n))
if mm==ana:
print("correct.well done!".format(mm))
b+=1
else:
print("No.the correct answer is {}".format(mm))
print("You got {} out of 10 question right".format(b))
print("well done!")
سلام
چرا این کد اجرا میگیرم فقط دستور else اجرا میکنه هر بار
حتی وقتی جواب ضرب درسته باز دستور else اجرا میکنه و اصلا دستور if اجرا نمیکنه
سلام
این خط:
ana=input("what is {} times{} ? ".format(a,n))
ورودی رو باید به عدد تبدیل بکنید، وقتی از کاربر ورودی دریافت میکنید به صورت string دریافت میشه و باید به type مورد نظرتون تبدیلش بکنید.
https://www.freecodecamp.org/news/how-to-convert-strings-into-integers-in-python