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

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes