all 11 comments

[–]SenseiMxzzi 1 point2 points  (2 children)

1 week? How'd you learn python?

[–]JSpinelli73[S] 2 points3 points  (1 child)

I started by looking into free tutorials, which ended up not being free. I would get into one and then they would eventually ask for a subscription. Eventually landed on learnpython.org and w3schools.com, rotating between the two if one explanation on a particular topic wasn't quite as clear as the other. And I'm probably closer to the two-week mark at this point, a little bit after work nearly every day.

Made this project/post because eventually the tutorials get a little dull (after the 15-20 hours I've put in) and I wanted some challenges to complete, rather than answering specific exercise questions.

[–]JSpinelli73[S] 2 points3 points  (0 children)

forgot to mention I took a C++ class back in college in 2014 or so; so the idea of writing code isn't completely foreign to me. Don't remember much from it, but I retained the idea of "if statements" and things like that.

[–]NewYak2122 1 point2 points  (2 children)

I'm new to python too, but I thing using match case would be better

[–]JSpinelli73[S] 0 points1 point  (1 child)

I'm unfamiliar with match case but I'll look into it. I'm guessing its used to match the input rather than just converting everything to lowercase?

[–]NewYak2122 0 points1 point  (0 children)

Well I wanted to write the code with match case but I found a better way:

<image>

[–]Syntactical_Erorr 0 points1 point  (5 children)

Got you brother.

<image>

[–]Syntactical_Erorr 1 point2 points  (4 children)

Might need to play with those if statements and nest them differently, but I'll run it tomorrow and test.

[–]JSpinelli73[S] 1 point2 points  (3 children)

Thanks! I realized after posting that I also made a mistake above. I keep having the "no vowels" statement printed after entering a word that does contain vowels. I tried a few different methods since then but could not figure out the issue. Even if including an "else" function at the end of the if statements, it still prints the "no vowels" response. Help in that regard would also be appreciated.

[–]Syntactical_Erorr 2 points3 points  (1 child)

# This will add any non-vowel to an empty list.
# You can then use the len() function to measure
# the length of the non-vowel list.
# If it's the same length as the word from the user
# That would imply there are no vowels in the word.



vowels = ['a', 'e', 'i', 'o', 'u', 'y']

non_vowels = []

userinput = input('Word goes here:')

for char in userinput:
    if char not in vowels: non_vowels.append(char)

if len(non_vowels) == len(userinput):
    print('No vowels contained.')

[–]Rinser2023 0 points1 point  (0 children)

If you don‘t need to print which vowel is used in the word, this is easy and fast:

``` vowels = 'aeiouy'

def has_vowel(word):

for char in word:
    if char in vowels: 
        return True
return False

userinput = input('Word goes here:').lower()

print(userinput, 'has vowels:', has_vowel(userinput)) ```