Why does it not work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does it not work?

Input (“five plus five is:”) If input == ten: Print (“Correct!”) Why does it not work in Python? Thanks!

12th Jan 2018, 10:05 PM
Eduardo Franco
Eduardo Franco - avatar
2 Answers
+ 3
You have to storage the input() value in a variable, then you have to call that variable a = input("five plus five is:") if a == "ten": print("Correct!")
12th Jan 2018, 10:11 PM
Sebastián Zapata
Sebastián Zapata - avatar
+ 9
Here are a few points: 1. Python is case sensitive and doesn't recognize 'Input'. Always use 'input'. 2. Same with 'Print'. Always use 'print'. Also 'If'. Always use 'if'. 3. The result of input() is always a string and can only be compared with another string, so you should compare it with "ten" as @Sebastian said, not ten. 4. input() is a function, but input is just a word - always use input with parentheses, i.e. input(). 5. You can either store the string value of the user's input (if you plan to use it again) in a variable as @Sebastian suggested, or, if it's going to be a one time use, you can shorten your code to: if input("five plus five is:") == "ten": print("Correct!")
13th Jan 2018, 12:07 AM
David Ashton
David Ashton - avatar