これは単語の文字列を検索する必要があります。どのように大文字小文字を区別しないのですか?
sentence= input("Enter a sentence")
keyword= input("Input a keyword from the sentence")
keyword.upper() == keyword.lower()
words = sentence.split(' ')
for (i, subword) in enumerate(words)
if (subword == keyword)
print(i+1)
if (keyword not in sentence)
print("Sorry, that word wasnt found in the sentence")
これまでの私のコードである次は私が私のコードに追加することができるもの
keyword.upper() == keyword.lower()
動作しませんか? 、キーワードの小文字バージョンで刑の小文字バージョンを比較する必要が
sentence = input("Sentence: ")
keyword = input("Keyword: ")
if keyword in sentence:
print("Found it!")
else:
print("It's not there...")
は大文字小文字を区別しないになるために:
"' keyword.upper()== keyword.lowerは() '" 達成するために何を想定していますか? –
offcourse keyword.upper()== keyword.lower()は常にFalseを返します – Harsha
@HarshaBiyani: "42" –