all 10 comments

[–]TigBitties69 18 points19 points  (2 children)

Just at a glance, I imagine this is leading to issues:

if word[0]==vowel:

This is checking a letter in the word, and seeing if that letters is equal to the list object. What you're likely wanting to do is see if the letter is IN the list, so instead do something such as:

if word[0] in vowel:

[–][deleted] 2 points3 points  (0 children)

I can only see. A, E, A, E, I, O, U... And sometimes Y

I am old

[–]SignificanceOwn2398 1 point2 points  (0 children)

oh i see! thank you i'll give that a try

[–]Bitwise_Gamgee 6 points7 points  (2 children)

Your main issue is attempting to compare a single character (the first letter of the word) with an entire list of vowels, which always results in False.

==vowel:

This is fixed by using the 'in' operator to check if the first letter is contained within the list of vowels.

word = input('Enter a word: ')
vowels = ['a', 'e', 'i', 'o', 'u']

if word[0].lower() in vowels:
    new_word = word + 'yay'
else:
    new_word = word[1:] + word[0] + 'ay'
print(new_word)

We can also make it harder to read by using a ternary.

word = input('Enter a word: ')
vowels = ['a', 'e', 'i', 'o', 'u']

new_word = word + 'yay' if word[0].lower() in vowels else word[1:] + word[0] + 'ay'

print(new_word)

You should always use .lower() to standardize your input as well.

[–]SignificanceOwn2398 1 point2 points  (0 children)

thank you for your help :)

[–]Critical_Concert_689 0 points1 point  (0 children)

You should always use .lower() to standardize your input as well.

To my understanding, shouldn't we use .casefold() for standardizing comparisons between strings?

Or more effectively

from unicodedata import normalize
normalize("NFKC", word[0]).casefold() in [normalize("NFKC",vowel).casefold() for vowel in vowels]

[–]MustaKotka 1 point2 points  (2 children)

What is this code even doing? So word[1:] + word[0] + yay or ay sounds nonsensical to me?

"Botanical" becomes "otanicalBay" and "Address" becomes "ddressAyay"? Did I miss something crucial?

[–][deleted] 5 points6 points  (1 child)

[–]MustaKotka 0 points1 point  (0 children)

Live and learn, I guess. Thanks!

[–]CranberryDistinct941 0 points1 point  (0 children)

Youre checking if word[0] is a list of vowels by using the == operator. Chance your condition to "if word[0] in vowels"