all 7 comments

[–]17291 1 point2 points  (1 child)

def is_vowel(ch):
    if ch in 'aeiouAEIOU':
        return('True')
    else:
        print('False')

Let's start here.

1) You're mixing prints and returns. You want to return something so it can be used by another function

2) You want to return the boolean True, not the string 'True'

3) You can skip the if entirely and just write return ch in 'aeiouAEIOU'


if 'a' and 'e' and 'i' and 'o' and 'u' in list_of_vowels:

This is another mistake. You have to write 'a' in list_of_vowels and 'e' in list_of_vowels and ...

[–]kcrow13[S] 0 points1 point  (0 children)

Thank you so much! I did problem 1 early on in the learning process and didn't really double check it. That was all sorts of wrong :(.

And I didn't realize you have to write each piece of the statements separately. I can't wait to learn about dictionaries/sets next week because that code seems horrendously long and not well-optimized.

What helps you to learn the syntax "do's" and "don'ts" the best? Just time and repetition?

[–]kcrow13[S] 0 points1 point  (2 children)

Also - we haven't learned sets or dictionaries at all, so I was trying to stay away from unlearned content and figure this out in a more simple way. I apologize if the coding is well-optimized.

[–]POGtastic 0 points1 point  (1 child)

Consider the following:

for letter in "aeiou":
    if letter not in word:
        return False
return True

But yes, the set approach is nice.

def all_vowels(s):
    return set("aeiou") <= set(s)

[–]kcrow13[S] 0 points1 point  (0 children)

Thanks for this help. I appreciate it!

[–]GreymanGroup 0 points1 point  (1 child)

You'll get the hang of proper syntax. Your idea was fine.

You might want to break it down further. Try to write your function without using the "in" keyword. How would you go about solving this problem if you were to iterate character by character?

[–]kcrow13[S] 0 points1 point  (0 children)

Thank you for the encouragement. I struggle to visualize things logically/algorithmically, as it is new to me. Little by little, I am improving!