Today's record is a bit late, not because I'm lazy and didn't study. It's because I've been studying if and else for 7 days, and I wanted to ask chatgpt to help me review, but the questions it raised were always beyond my scope. I think it must be that I asked the wrong questions, after all, how could a machine be wrong!
Record
- Today I learned about nested if statements, where each if statement within the nesting will be executed. However, elif will only be executed when the condition of the previous if statement is false.
- Indentation is crucial in Python, especially for nested if statements. But nowadays, editors support automatic code formatting, right? Maybe I won't need to pay attention to this issue once I become more experienced.
CODE
print("👮♂️ Fake Fan Finder 👀")
game = input("what's your favourite game? ")
if game == "Genshin Impact":
name = input("Oh really?! Name me any of the characters? ")
if name == "Hu Tao":
work = input("where does Hu Tao work? ")
if work == "Wangsheng Funeral Parlor":
print("You are a true fan")
else:
print("You are a fake fan")
elif game == "Honor of Kings":
print("You are a true man for 5 seconds")
else:
print("The game you play is quite niche!")