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:
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.
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:
1 2 3 4 5 6 7 8 9 10 11 |
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!" ) |
Big thanks to everyone who is ready to help.