Dec-10-2023, 01:23 AM
(Jun-14-2020, 04:58 PM)buran Wrote:usernames = [] for username in usernames: if username == 'admin': print("Hello admin, would you like a status report?") if username != 'admin': print("Hello " + username + ", thank you for logging in again!") else: print("We need more users!")It has to beelse
related to thefor
loop, not as part ofif
.`
else
part of the loop is executed if nobreak
statement is hit inside the loop.
Note that it doesn't make sense to iterate over users in the list - if the list is not empty it will print something for every user in the list and again will print the else part (because there is no break inside the loop)
Nice!! This one stumped me!!