有没有更简单的方法来检查字符串中的字符?谢谢:dPython 3.x短版本的代码
check = input("Put in the letter: ")
word = "word"
if(check == word[0]):
print(check)
if(check == word[1]):
print(check)
if(check == word[2]):
print(check)
if(check == word[3]):
print(check)
快速注:@leistungsabfall的代码将打印的字符一次eventhough而我的代码像你原来的代码打印n次,如果发生信多次,可能会发生多次,在这个词里。 –