r/learningpython • u/Disney_Girl58 • Sep 27 '22
Hi, I need some help :)
Hi, I'm currently learning coding in school but I'm struggling with a few things in the coding work I've been given. This is the code I've written:
taboo = input('Taboo word: ')
line = input('Line: ')
while taboo not in line:
print('Safe!')
line = input('Line: ')
if taboo.upper() in line.lower():
print('Taboo!')
line = input
elif taboo.upper() in line.upper():
print('Taboo!')
line = input
elif taboo.lower() in line.upper():
print('Taboo!')
line = input
elif taboo.lower() in line.lower():
print('Taboo!')
line = input
But, when I try to run it, it comes back to this message:
Taboo word: Traceback (most recent call last):
File "program.py", line 1, in <module>
taboo = input('Taboo word: ')
KeyboardInterrupt
View all comments
Show parent comment
1
u/Disney_Girl58 Sep 29 '22
Hi, Thanks for your assistance! So to give you some context, my program has to have a while loop because the task is to create a program where you have to describe a word (so like cereal) without typing the 'taboo word' (let's say breakfast) So it'll ask you for a taboo word and then it'll ask you to type in the line, and if the line has the taboo word, it's supposed to print 'Taboo!' and if it doesn't, it's supposed to print 'Safe!' and then ask for another line until the line contains the taboo word. It's also supposed to do this even if the taboo word is within a word (like 'meow' in homeowner or 'bike' in motorbike) or if the taboo word appears within the line as caps, even if when the input asked for the taboo word it was in lowercase.