![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Not quite... look more closley at these lines:
vowels = "aeiou"
for i in vowels:
loc = source.find(i)
Note that i is a variable. Greg Leo |
| Will it get rid of all the vowels, or just some? If some, which ones specifically? This also depends on whether you are referring to program a. or b. Kelly Lyons |
if loc <> -1: source = source[:loc]+source[loc+1:]
| Reason through it. What does it mean for a number to be greater than or less than a -1? Why would the method find return a -1? As for the second line, remember that, for example... string[0:4] would return the 0th 1st 2nd and 3rd characters of a string but not the 4th. Just like range, JES stops before the last number. source[:loc] is basicly like saying "Give me everything up to but not including the "loc" position of source. Greg Leo |
| That's correct, but notice that the string is first made lower case and then the vowels are replaced. Why is this necessary? Greg Leo |