an_letters = "aefhilmnorsxAEFHILMNORSX"
word = input("I will cheer for you! enter a word:")
times = int(input("Enthusiasm level (1-10):"))
i = 0
while i < len(word):
char = word[i]
if char in an_letters:
print("Give ma an " + char + "! " + char)
else:
print("Give ma a " + char + "! " + char)
i += 1
print("What does that spell?")
for i in range(times):
print(word, "!!!!")
我很努力去理解char = word[i]
做什么。 Afaik在Python中没有char
类型,只有str
我认为这只是一个变量,它对变量word
进行索引。但我不明白i
是指什么?我们不应该用数字来表示位置吗?python和字符串切片使用文字?