This code doesn't work need help Thanks (Pyg problem)


#1

Hi and thank you for taking a look at my problem
Here is my code:

pyg = 'ay'

original = raw_input('Entrez un mot :')

if len(original) > 0 and original.isalpha():
    print original
    mot = original.lower()
    premiere = mot[0]
    if premiere != "a"or "e" or "i" or "o" or "u" or "y":
        nouveau_mot = nouveau_mot[1:] + pyg
        print nouveau_mot
    else:
        nouveau_mot = nouveau_mot + pyg
        print nouveau_mot
else:
    print 'vide'

When I run it I get ayayayay
I found another way to solve the problem since but I would like to know why this way failed thank you


#2

@captainmorgan95000 can you repost your code with formatting. it makes it easier to analyze

if you want to format your code when you paste it here you have three options

  1. select the code (after you paste it here) and press ctrl + k or
  2. select the code(after you paste it here) and press </> in the tools pane
  3. put this character ` three times at the begining and end of code

#3

Allright thank you there is a clean code to analyze thanks


#4

Maybe you are using the french version of the exercise but this should work

pyg = 'ay'

original = raw_input('Entrez un mot :')

if len(original) > 0 and original.isalpha():
    #print original
    mot = original.lower()
    premiere = mot[0]
    nouveau_mot = ""
    
    #your condtion here was not put in ther right
    #format
    if premiere not in "aeiou":
        nouveau_mot = mot[1:] + premiere +pyg
        print nouveau_mot
    else:
        nouveau_mot = mot + pyg
        print nouveau_mot
else:
    print 'vide'

#5

Yes it works thanks ! I did not know that "not in" condition.