Python Forum

Full Version: help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
this is the code
num=16
for i in range(1,16):
print(num,'x',i,'=',num*i)
import random
number=random.randint(1,16)
for counter in range(1,6):
ans=int(input('16','x',number,'=',number*16))
if ans==number*16:
print("well done you got it right")
else:
print("Sorry your answer was wrong the correct answer is:"+str(number*16))

this is the error

Traceback (most recent call last):
File "main.py", line 7, in <module>
ans=int(input('16','x',number,'=',number*16))
TypeError: input expected at most 1 argument, got 5
Why are you trying to pass all those things to input? It takes a single argument that is the prompt you want it to print out when it reads input from the command line.
(Jan-05-2021, 09:49 AM)ndc85430 Wrote: [ -> ]Why are you trying to pass all those things to input? It takes a single argument that is the prompt you want it to print out when it reads input from the command line.
thanks for your help
i fixed it


num=16
mark=0
for i in range(1,16):
print(num,'x',i,'=',num*i)
import random
number=random.randint(1,15)
print("what is the answer to this question",number,"* 16=")
q1=number*16
ans=int(input())
if ans==q1:
print("correct")
mark=mark+1
else:
print("incorrect")
number=random.randint(1,16)
print("what is the answer to this question",number,"* 16=")
q2=number*16
ans=int(input())
if ans==q2:
print("correct")
mark=mark+1
else:
print("incorrect")
number=random.randint(1,16)
print("what is the answer to this question",number,"* 16=")
q3=number*16
ans=int(input())
if ans==q3:
print("correct")
mark=mark+1
else:
print("incorrect")
number=random.randint(1,16)
print("what is the answer to this question",number,"* 16=")
q4=number*16
ans=int(input())
if ans==q4:
print("correct")
mark=mark+1
else:
print("incorrect")
number=random.randint(1,16)
print("what is the answer to this question",number,"* 16=")
q5=number*16
ans=int(input())
if ans==q5:
print("correct")
mark=mark+1
else:
print("incorrect")
print("your marks out of 5 are", mark,"/5")