Missed the deadline to enter it in to be corrected, but still want to follow the course. Would someone mind correcting my work and telling me where I can improve on/be more efficient? Thanks!
Set 1:
Assume s is a string of lower case characters.
Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should print:
Number of vowels: 5
My ans:
Spoiler (Click to View)
Set 2:
Assume s is a string of lower case characters.
Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print
Number of times bob occurs is: 2
My ans:
Spoiler (Click to View)
Now, I struggeled a lot with the final one, and was wondering if anyone could give me a couple of hints on how to do it without fully telling me. Thanks in advance for the help!
Pastebin for answer 1/2: http://pastebin.com/yATSNcab
Final Question:
Assume s is a string of lower case characters.
Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print
Longest substring in alphabetical order is: beggh
In the case of ties, print the first substring. For example, if s = 'abcbcd', then your program should print
Longest substring in alphabetical order is: abc
Set 1:
Assume s is a string of lower case characters.
Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should print:
Number of vowels: 5
My ans:
Spoiler (Click to View)
Set 2:
Assume s is a string of lower case characters.
Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print
Number of times bob occurs is: 2
My ans:
Spoiler (Click to View)
Now, I struggeled a lot with the final one, and was wondering if anyone could give me a couple of hints on how to do it without fully telling me. Thanks in advance for the help!
Pastebin for answer 1/2: http://pastebin.com/yATSNcab
Final Question:
Assume s is a string of lower case characters.
Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print
Longest substring in alphabetical order is: beggh
In the case of ties, print the first substring. For example, if s = 'abcbcd', then your program should print
Longest substring in alphabetical order is: abc

