Reputation:
name=input("Enter your name: ")
message=input("Enter your message:")
namefinal=list(name)
for namefinal in message:
del(namefinal)
print(message)
I need help with creating a program that gets a message from the user and removes all of the letters that are in the user’s name. I made the user input(name)
into a list but I don't know how to delete the letters. For example if I type in Charan
and the message is Lebron James
it will delete r,a,and n from Lebron James, making it Lebo Jmes
.
Upvotes: 1
Views: 428
Reputation: 67
you can do like this:
name=input("Enter your name: ")
message=input("Enter your message:")
namefinal = ''
for letter in name:
if letter not in message:
namefinal += letter
print namefinal
Upvotes: 1
Reputation: 42758
You can use replace, to remove letters:
for letter in name:
message = message.replace(letter, '')
Upvotes: 0