I’ve been self studying Python Crash Course and this is a exercise to check username . I know if I put the user2 under second for loop, the result is Ok. What I don’t understand is if I mistakenly put user1 under (user2)for loop .The output is only the last item in current_user list. I was expecting all value in current_user list to be printed. But nooo it only print the last item of the list.
current_users = ['eric', 'willie', 'Hhum', 'admin', 'Erin', 'Ever']
new_users = ['sarah', 'WILLIE', 'PHIL', 'ever', 'Iona']
current_users_lower = []
for user1 in current_users:
current_users_lower.append(user1.lower())
for user2 in new_users:
if user2.lower() in current_users_lower:
print(f"Sorry {user1}, that name is taken.\n")
else:
print(f"Great, {user1} is still available.\n")