ユーザーが単語を検索するように求められたら、大文字小文字を区別しないようにしたい。Python 3.4.3では、大文字小文字を区別しないようにするにはどうすればよいですか?
import string
usersentence= input("Please type in a sentence without punctuation: ")
usersentence = ''.join(ch for ch in usersentence if ch not in set(string.punctuation))
print (usersentence.upper())
for i in range(1): # number of words you wont to search
word= input("Please enter a word you want to search for in the sentence: ")
words = usersentence.split(' ')
passed = False # Something to check if the word is found
for (i, words) in enumerate(words):
if (words == word):
print("your word appears in position(s): ")
print(i+1)
passed = True # The word has been found
if not passed:
print("Sorry your word does not seem to be here")
使用 '.lower()'と
continue
変数名を置き換え? – martijnn2008各 'input()'の後に 'lower()'を使用しますか? – TigerhawkT3
私はどのようにコード –