+ 1
Why is the output nothing? Im a beginner so please dont be hard on me
x = 41 if x > 42: print(str(x) + â is greater than 42â) if x < 43: print(str(x) + â is less than 42â) Please assume I indented correct. I am using python
3 Answers
+ 5
41 is not greater than 42 . And since "if x<43" is inside "if x>42", it isn't executed as well.
You can have "if x<43" with same amount of indentation as the above if and you might get the output you are looking for!
0
to piggy back off of Abhay , your second if statement will only run if x is greater than 42. if you want the second if statement to run all the time, you will need to unindent the second if statement as well. it would look something like this:
x=41
if x>42:
print(fâ{x} is greater than 42â) # this is a format string that allows you to insert variables within a string using curly brakets
if x<42:
print(fâ{x} is less than 42â)
0
And in addition to the answers before check your double quotes!
this is a double quote: "
and that have you used: â ! Its not a right double quote. So you are running into error.