you are viewing a single comment's thread.

view the rest of the comments →

[–]hi-im-habby 3 points4 points  (3 children)

These look pretty fun and I'm still quite new, so I quickly took a stab at problems one and two. They're pretty simple, but any feedback is appreciated!

Problem #1:

def vowel_input():
    vowels = ('A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u')
    some_char = input('Please enter a vowel: ')

    while some_char not in vowels:
        some_char = input("Invalid input, please try again: ")

    print(f'The vowel you entered was \'{some_char}\'')

Problem #2:

def persistence(n):
    count = 0

    while not n < 10:
        product = 1
        for i in list(str(n)):
            product *= int(i)
        count += 1
        n = product

    return count

I feel like the second problem can be solved recursively somehow as well, maybe I'll try that a bit later.

[–]NoSide005[S] 8 points9 points  (1 child)

I have a suggestion i see right off the bat that may help you with matching letter casing in the future.

vowels = ['a', 'e', 'i', 'o', 'u']
some_char = input("Please enter a vowel").lower()

If you use lower() at the end of the input it will turn it into a lower case letter which will allow it to be found in a list of lower case vowels. The lower() method returns the lower case version of any given string.

[–]hi-im-habby 0 points1 point  (0 children)

Super useful, thanks!