RESOLVED Hello Python community,
I am currently learning Python, so forgive me if this question is stupid or something really obvious. I was doing a task in the Python Crash Course book, it is a simple if-else syntax, which for some reason doesn't work. I even asked multiple AIs, but they couldn't solve this issue. Here is the code:
Big thanks to everyone who is ready to help.
I am currently learning Python, so forgive me if this question is stupid or something really obvious. I was doing a task in the Python Crash Course book, it is a simple if-else syntax, which for some reason doesn't work. I even asked multiple AIs, but they couldn't solve this issue. Here is the code:
usernames = [] if usernames: for username in usernames: if username == "admin": print(f"Welcome, Admin, do you wish to check the analytics?") elif username in usernames: print(f"Welcome, {username}, thanks for using our service.") else: print("The list is empty!")As you see, the usernames list is empty, but the print function in the else statement does not work. The output shows absolutely nothing. To make it clear, I always use the same device to code stuff and it works without any issues, and I am using the latest Python version.
Big thanks to everyone who is ready to help.