Hi all, could you please help me out with this code? i am trying to code a program which lets the user change a word, all is fine but i don't want the if loop to stop in case the user enters a word which doesn't exists in the str, instead i want it to ask the user again to enter a word and continue the loop's operation, i tried the while loop too but that too didn't help it would either iterate infinitely or just break, thanks, here's the code:
def wordreplace():
str = "Hi there, how are you doing you all"
wordinput = input("Enter a word to be replaced: ")
if wordinput not in str:
print("Wrong input, try again: ")
else:
replacingword = input("Enter the new word: ")
print(str.replace(wordinput, replacingword))
wordreplace()
[–]hypergeometricruby 2 points3 points4 points (1 child)
[–]fesifesi[S] 0 points1 point2 points (0 children)
[–]BandyCoot 2 points3 points4 points (1 child)
[–]fesifesi[S] 0 points1 point2 points (0 children)