Je bloque sur le Pyg Latin - 8 mot en l'air


hello, je ne sais pas ce qui cloche dans mon code :

premiere = "python"[0]

premiere = raw_input("python")

if len(premiere) > 0 and original.isalpha():

mot = original.lower()
print original # affiche "p"

print 'vide'

auriez-vous une piste ? :slightly_smiling: merci !

hello, I do not know what's wrong in my code:

first = "python" [0]

first = raw_input ("Python")

if len (first)> 0 and original.isalpha ():

 original.lower word = ()
 original print # print "p"

print 'empty'

Would you have a clue? : Slightly_smiling: thank you!



I will try to explain you what you did wrong and why it won't work.

Let me correct your french code, because it has less errors :smiley:

You want to set the first letter of python to premiere, right? But shouldn't you take the first letter of the word, you type in raw_input? :slightly_smiling:

Let's try to fix this, by typing:

premiere = raw_input("python")
first_premiere = premiere[0]

Just a little hint -> you don't have to type the word you want to use here raw_input("python"), you can put whatever message you want, for example: raw_input("Please type in a word: ")

You should check if your word is alphanumeric, not original :wink:

 if len(premiere) > 0 and premiere.isalpha():

original.lower(), will make your word lowercase: Hello -> hello, but it will do it for original, and not your word you typed in.
You can use the function lower() for your own variable you typed in:

mot = premiere.lower()

and then print your own word:

print mot

but not: print original, because you don't have a variable called original :slightly_smiling:

So your code should look like this, in the end:

premiere = raw_input("python")

first_premiere = premiere[0]

if len(premiere) > 0 and premiere.isalpha():

    mot = premiere.lower()
    print mot # affiche "p"

    print 'vide'


thank you ! I finally :slightly_smiling:


Did it work? :smiley:


the test was conclusive :slightly_smiling:


I hope you understand my explanation as well and will learn from your mistakes.

Have fun at coding :smile:


I'm learning slowly but surely :slightly_smiling: thank you again for the hand :smiley:


You're welcome ^^

Feel free to ask me whenever you need help :grin: