I'm new to Python and learning. I'm trying to write a program to:
- User input full name (with space)
- Check duplication to a list (I used split and join to compare strings)
- If find a duplication, re-input new name
- If not, simply break the loop and print "Thanks"
- I only need to print "Duplicated" or "Thanks" 1 time, not multiple times with For loop.
My issue is when I cant re-call the input with my code (with duplicated input) or break the loop (after new name)
list=["M T", "Smith Jenkins", "P T", "C P"]
while True:
user=input("Your full name :")
usercheck="".join(user.split())
print(usercheck)
for i in list:
j="".join(i.split())
if usercheck ==j:
print("Duplicated ! Please enter new name")
else:
print("Thanks")
break