What's the logical value of "string" in python?
- by Kamran
I erroneously wrote this code in python:
name = input("what is your name?")
if name == "Kamran" or "Samaneh":
print("That is a nice name")
else:
print("You have a boring name ;)")
It always prints out "That is a nice name" even when the input is neither "Kamran" nor "Samaneh".
Am I correct in saying that it considers "Samaneh" as a true? why?
By the way, I already noticed my mistake. The correct form is:
if name == "Kamran" or name == "Samaneh":