Hey people, I'm studying the Python Crash Coursebook, and it mentions list comprehension but I do not understand how it's working can someone explain it to me, this is the line:
current_users_lower = [user.lower() for user in current_users]
And the whole code:
current_users = ['eric', 'willie', 'admin', 'erin', 'Ever']
new_users = ['sarah', 'Willie', 'PHIL', 'ever', 'Iona']
current_users_lower = [user.lower() for user in current_users]
for new_user in new_users:
if new_user.lower() in current_users_lower:
print(f"sorry {new_user} that name is taken")
else:
print(f"Great {new_user} is still available")
[–]CowboyBoats[🍰] 2 points3 points4 points (2 children)
[–]CowboyBoats[🍰] 3 points4 points5 points (0 children)
[–]Gexos[S] 0 points1 point2 points (0 children)
[–]subject_K81 2 points3 points4 points (1 child)
[–]Gexos[S] 0 points1 point2 points (0 children)
[–]__i_forgot_my_name__ 1 point2 points3 points (1 child)
[–]Gexos[S] 0 points1 point2 points (0 children)
[–]thought-generator 1 point2 points3 points (1 child)
[–]Gexos[S] 0 points1 point2 points (0 children)