Correct the following code to print the last item in the following list.改正下列代码输出列表中最后一个元素。spam = ['cat','ant', 'dog', 'elephant', 'mouse']print(spam[5])
查看答案
Print the titlecased form of the following names.改正代码将列表names中的字符串首字母大写输出。names = ['tom', 'harry', 'amy']for s in names:print(s.title, end = ' ')
Correct the definition of the following class to print 'Hello'.改正下列类的定义输出'Hello'。class Foo:def show():print('Hello')a = Foo()a.show()
Correct the following codes to count the vowel letters in s.改正下列代码统计字符串s中元音字母的个数。s = 'Life is short, you need Python.'count = 0for c in s:if c.lower() in "aeiou":count++print(count)
Correct the following codes to count all the input symbols ending with #.改正下列代码统计以#结束的字符个数。count = 0while x=input()!= '#'count += 1print(count)