Nov-23-2019, 04:48 PM
I'm trying to write a program which prompts the user for a word. Then, the program will ask what letter should be removed, only allowing one letter at a time, and how many times they want to continue this removing process, beforehand. My code works for the first round where it successfully removes that letter. But afterwards, it goes a bit haywire and I have no clue why. I'm wondering if there are any noticeable bugs and what I can do to get it to work successfully. If someone can help me figure this out, that would be great...
new_word = ""
word = str(input("Please enter a word: "))
removed_letter = str(input("Which letter do you want to see removed?: "))
while len(removed_letter) > 1:
print("Only one letter at a time.")
removed_letter = str(input("\nWhich letter do you want to see removed?: "))
process_repeat = int(input("How many times do you want to repeat this process?: "))
while process_repeat > len(word):
print("You don't even have that many letters in your word")
process_repeat = int(input("\nHow many times do you want to repeat this process?: "))
while len(removed_letter) > 1:
print("Only one letter at a time.")
word = str(input("Please enter a word: "))
removed_letter = str(input("Which letter do you want to see removed?: "))
for num in range(process_repeat):
for num in range(len(word)):
if word[num] == removed_letter:
new_word += ""
else:
new_word += word[num]
print(new_word)
word = new_word
removed_letter = str(input("\nWhich letter do you want to see removed?: "))
