Цель моего кода - ввести строку от пользователя и превратиться в список, не учитывающий регистр. Затем мне нужно взять вторую строку от пользователя, а затем вывести позицию второй данной строки. Это мой код:Как отлаживать мой код Python?
UserSentence = input('Enter your chosen sentence: ') #this is where the user inputs their sentence
from string import punctuation #this 'fetches' the punctuation from the string
tbl=str.maketrans({ord(ch):" " for ch in punctuation})
UserSentence = UserSentence.lower().translate(tbl).split()#.split() turns the input sentence into a list,...
#...this will help to identify where a word appears...
#...in the sentence. The .lower() also turns the...
#...string into lowercase so it is not case sensitive.
UserWord = input('Enter a word from the sentence: ')#this is where the user inputs their word from the sentence
UserWord = UserWord.lower()#.lower() is used to make UserWord not case sensitive
for i in range(len(UserSentence)):
if UserSentence (i) == UserWord:
print ('Your chosen word appears in: ')
"Нужна помощь отладки мой код пожалуйста" - Расскажите нам, что случилось. – hlt
Голосование, чтобы закрыть как не MCVE. – halfer