课程第三讲
school = 'Massachusetts Institute of Technology'
numVowels = 0
numCons = 0
for char in school:
if char == 'a' or char == 'e' or char == 'i' \
or char == 'o' or char == 'u':
numVowels += 1
elif char == 'o' or char == 'M':
print char
else:
numCons -= 1
print 'numVowels is: ' + str(numVowels)
print 'numCons is: ' + str(numCons)
How many times does o
print out? Disregard the o
's in last two print statements.
0, if 为True ,就不判断下面的elif else.
What will the value of the variable numVowels
be?
11,大写I没算
What will the value of the variable numCons
be?
-25,加空格。