|Welcome to CS1315. Click on the python to add comments.|
|This page removed for FERPA compliance|
Midterm Exam 2 Review Fall 2004: Find the First from the Last
Post answers, comments, and questions here!
(Back to Fall2004 Midterm 2 Review)
on page 240 of text– count(something) is the clue.. but I don't know how to get it to count the a's
oops- wrong place to add the question— sorry
def findFirstREMOVEDe(string, name):
for n in new[:]:
|Getting there. The split() function reqires input. What do you think you would want to split on to separate all the words? Also, your function will look through all the names. What if one person's first name is the same as someone else's last name? So you only want to search through the last names. REMOVEDw do you search only every other item in a list (hint range)? Keep working on it. Student1594|
for names in range(0,len(names),2):
if names == lastname:
why doesn't this work?
wouldn't 0 in the range function be the first term?
for index in range(1,len(names),2):
if lastname == names[index]:
print names[index - 1]
Link to this Page