Link to home
Start Free TrialLog in
Avatar of nav2567
nav2567Flag for United States of America

asked on

python code assistance.

Hello,

I am getting these error with the below code.  Please advise how to fix.  Thanks!

TypeError: input expected at most 1 argument, got 5

maxnumber = 10
userstring = input(“Please enter a number”)
usernum = int(userstring)

While usernum > maxnumber:
   print("You enter:”,usernum,”The biggest number is”,maxnumber,”Please enter again”)
   userstring = input(“You enter:”,usernum,”The biggest number is”,maxnumber”,”Please enter again”)
   usernum=int(user string)

print(“Thanks for entering:”,usernum)

Avatar of HainKurt
HainKurt
Flag of Canada image

you have to use + in print function

print(You enter:”,usernum,”The biggest number is”,maxnumber,”Please enter again”) 
>>>
print(You enter: ” + usernum + ” The biggest number is ” + maxnumber + ” Please enter again”)
Avatar of Norie
Norie

Try this.
maxnumber = 10
userstring = input('Please enter a numberL\n')
usernum = int(userstring)

while usernum > maxnumber:
   userstring = input(f'You enter:{usernum}, The biggest number is: {maxnumber}, Please enter again:\n')
   usernum=int(userstring)

Open in new window

Avatar of nav2567

ASKER

HainKurt, I am getting another type error which is "can only concatenate str (not "int") to str

Norie, I tried your way as well.  It is not showing usernum and maxnumber as numbers but this result:

You enter:(usernum), The biggest number is: (maxnumber), Please enter again:
Can you post the exact code you are using?
Avatar of nav2567

ASKER

I updated the original code I submitted, but it is pretty much similar.  Please check again.  
Avatar of nav2567

ASKER

run it and you will see the error.  Any number smaller the maxnumber will be printed fine.  
What happens if you copy and paste the code I posted and run it?
Avatar of nav2567

ASKER

I will try that later and update.  Thanks again...
Avatar of nav2567

ASKER

Norie,

I think I tried it this morning and I got the below if I enter the number bigger than the maxnumber.  

You enter:(usernum), The biggest number is: (maxnumber), Please enter again: 

Instead, I want the following:

You enter:12, The biggest number is: 10, Please enter again:

I will run it again later and update.  
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nav2567

ASKER

Ah...I see.  I have to use the curly bracket instead.  I think it will work.  I will try.  Thank you!!!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nav2567

ASKER

Yes, HainKurt, I think your way will work too.  I am going to try both ways and update again.  Thanks again. 
Avatar of nav2567

ASKER

All is well.  Thanks everyone!!!