Lesson 11: Bubble sort

posted Jan 25, 2019, 8:05 AM by Attila Lengyel
names = ["Attila"]

name = ""
while name != "exit":
name = input("Give me a name:")
if name == "exit":
continue

if name in names:
print("You already have this name!")
continue

for i in range(0, len(names)):
if name < names[i]:
names.insert(i, name)
break
if i == len(names) - 1:
names.append(name)

print(names)
Comments