Author Topic: Does anyone know python  (Read 974 times)

I need help with a problem I have... I have to make a python pyglatin translator as a test project and I'm stuck and puzzled look

Code: [Select]
pyg = 'ay'
original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
new_word = word
sliceword = new_word[1:6]


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

    if first == 'a' or first == 'e' or first == 'i' or first == 'o' or first == 'u':
       
        new_word = word + pyg
        print (new_word)
       
    else:
   
        new_word = sliceword + pyg
        print (new_word)
       
else:

print ('Enter something valid please...')

look at the course if you want, it's free http://www.codecademy.com/courses/python-beginner-2W5v7/1/5?curriculum_id=4f89dab3d788890003000096

I need to do

Code: [Select]
Inside the else part of your if/else block that checks the first letter of the word, set the new_word variable equal to the translation result for a word that starts with a consonant.

Replace the print 'consonant' bit with print new_word. Make sure to test your code with a word that starts with a consonant!

The code is left unfinished, but I need all constant words to be like... google = ooglegay
I'm trying to slice the string, but can't seem to find a way to fit it in >:/. Any Ideas?

And I posted this in the off topic page because the coding help section is for torque only...
« Last Edit: December 03, 2013, 09:39:57 PM by chubaka452 »

pythong?
nice edit dork

pythong?
nice edit dork

Gosh one second I post this I see this LOL, I fixed it the second you posted,

Do you know what a dork is?


Proof that Bing is better !

Are you gonna to help or are you just gonna spam?

Code: [Select]
       print (new_word)
        
else:

print ('Enter something valid please...')
that's probably what is wrong

Code: [Select]
       print (new_word)
        
else:

print ('Enter something valid please...')
that's probably what is wrong

no... I left the code unfinished because I can't freaking slice the string and put it in the middle of the input GAH


copyed this into code academy
"  File "python", line 5
    new_word = word +
                     ^"
that's the error
fix it

copyed this into code academy
"  File "python", line 5
    new_word = word +
                     ^"
that's the error
fix it

no its not that either im TYPING lol that I can't slice the first letter of the string to go before the ay always

no its not that either im TYPING lol that I can't slice the string to go before the ay always
whats slicing? i used to code python a while ago but i forgot how


whats slicing? i used to code python a while ago but i forgot how

slicing is slicing duh lol you slice a code like

Code: [Select]
new = 'hi'
slicecode = new[0:1]
print(slicecode)
will print out just h because it sliced the i...

I used to code in Python, until I forgot everything because I preoccupied myself with C++ and C#

OMG I fixed it ^_^ I'm so happy lol

Code: [Select]
pyg = 'ay'
original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
new_word = word
sliceword = new_word[1:6]
omg = new_word[-6:1]


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

    if first == 'a' or first == 'e' or first == 'i' or first == 'o' or first == 'u':
       
        new_word = word + pyg
        print (new_word)
       
    else:
   
        new_word = sliceword + omg + pyg
        print (new_word)
       
else:

print ('Enter something valid please...')