Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help
#1
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
likes this post
Reply
#2
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.
Reply
#3
(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
Reply
#4
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")
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020