+ 3
My code gives me an output I didn't request for
My code gives me an output I didn't request for My question is I want to multiply any number inputted by the user to x But it's gives repeated number Pls help!!!💖 Eg If the user input"2" It gives 222222.... Instead of multiplying S=(input("Enter a number:") X=56 Print("Your number would be multiplied by a random number") Print("Your answer is?") Print(s) Print("There was an error while parsing ") Print("Wait while we process") Y=(input("processing:") f=s*x Print(f) Print ("What's is the random number") Z=(input("Your random number is:") G=(input("Was this helpful,true or false?:") Print("Thanks") Print ("Program ended")
8 Antworten
+ 7
https://code.sololearn.com/crxMyjB79yZp/?ref=app
Here it is solved since the user input is a string. Python treats the input as a string so.
U have to change the string to int.
example s=input("Number")
s=int(s).
The code reference solves your issue
+ 5
cast s to int, before the calculation
s = int(s)
+ 5
First ur input plss take it out of the bracket. S= input("Enter a Number") and plss print(s) the "s" is small whiles the one declared is capital.
Line 9 same mistake as the first one.
Line 10 ur s.
Line 13, 14 also
+ 4
Mind Python is case sensitive.
Print not equal to print
You read input into <S>
S = input ...
And somewhere down the line you go
print(s) # lowercase 'S'
S not equal to s
Variable <s> is yet to be defined.
+ 3
Mosunmola Alagbada
Save the code and share the link inside your thread Description (remove the raw text code first). That way people can track the changes you made, check and suggest on what changes still in need. If you put code as raw text like that, your changes cannot be tracked, and things go unsync making it harder.
Follow the below guide to sharing your saved code link 👇
https://www.sololearn.com/post/75089/?ref=app
+ 2
Thanks to you all
But when coding ,my S was in a lower case,I guess I didn't notice that when typing in the question.
Aside from that ,it's still giving me same reply!
+ 2
~swim~ I appreciate!