Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Print the first letter of the following string
- school = "McHenry County College"
- print school[0]
- # print the length of the school string
- print len (school)
- # Use a while loop to print each character (including spaces) in the school variable
- i = 0
- while i < len (school):
- letter = school[i]
- print letter
- i = i + 1
- # Slice school into three variables, print the variables
- print school[0:7], school[8:14], school[15:22]
- # use a while statement to search for the letter "e" in the contents of the school variable
- index = 0
- while index < len (school):
- if school[index] == str('e'):
- print index
- index = index +1
- # print the index of every location with the letter "e"
- # is this not the same problem as above?
- # rembember, you should not use the same variable twice in the same program
- # so if you used the variable index, use something else
- # Write the code to count the number of times the letter y appears in the school variable
- # print the total
- counter = 0
- for letter in school:
- if letter == 'y':
- counter = counter + 1
- print counter
- # create a variable named college and store the upper case version of the variable school in it
- college = school.upper()
- # check to see if Count is in the school variable
- def checkupper():
- if 'Count' in school:
- print "True"
- else:
- print 'False'
- checkupper()
- # check to see if count is in the school variable
- def checklower():
- if 'count' in school:
- print "True"
- else:
- print 'False'
- checklower()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement