Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

else if statement in python always provides the same result [closed]

$
0
0

I am working on an exercise to learn Python. The aim is to print out either 0, 20 or 100 based on an input, but the statement always gives me a "100":

x = input("what is your greeting?").lowerx = str(x)y = x.startswith("h")if "hello" not in x and y == "True":  print("20")if x == "hello":  print("0")else:  print("100")

I do not understand why.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>