Jumbled Funny Names Exercise in Python
import random
friendsNums=int(input("Enter number of friends: "))
friendsList=[]
for i in range(friendsNums):
names = input(f"Emter the name of friend {i+1}: ")
friendsList.append(names)
# print(friendsList)
lastNames=[]
firstNames=[]
for friend in friendsList:
nameParts=friend.split(" ")
lastNames.append(nameParts[1])
firstNames.append(nameParts[0])
print("\nYour new funny names are:\n")
for firstname in firstNames:
lastname=random.choice(lastNames)
lastNames.remove(lastname)
print(firstname, lastname)
print("\n")
Comments
Post a Comment
Write something to CodeWithAbdur!