That is because your else
condition executes before the last if
condition. So here I have change the order.
current_users = ['nedboy78', 'codingking678', 'johnnykapahala','jam95','python65','ANDY657']
new_users = ['hamlet56', 'python65', 'jam95','todds4','andy657']
current_users_convert = [current_user.lower() for current_user in current_users]
for new_user in new_users:
if new_user in current_users:
print(f'sorry username {new_user} not available pick a new username')
elif new_user in current_users_convert:
print(f"CANT USE {new_user} AS A USERNAME")
else:
print(f'username {new_user} is available')
Output:
username hamlet56 is available
sorry username python65 not available pick a new username
sorry username jam95 not available pick a new username
username todds4 is available
CANT USE andy657 AS A USERNAME
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…