Hey there,
I need help writing a python program that takes your input and gives it back in a pig latin type way.
This is what i got so far:

running = True

while running:
    
    word = raw_input("Enter word:")

    if word[0] in "aeiou":
        print word + "way"

    else:
        print word[1:] + word[0] + "ay"

But it won't take more than one word.
I'm not sure how to make it give each word back in that pig latin.

It would be great if anyone could help.

Thanks !

Editor:
Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help.

[code=python]
your Python code here

[/code]

Recommended Answers

All 4 Replies

heres a bit more:

running = True
sent = raw_input("Enter a sentence")

while running:

    for word in sent.split():
        if word[0] in "aeiou":
            print word + "way"

        else:
            print word[1:] + word[0] + "ay"

What i did was ask for a sentence at the start and then i split it into words using the sent.split() function, then i could do the whole sentence at once rather then one word at a time.

heres a bit more:

running = True
sent = raw_input("Enter a sentence")

while running:

    for word in sent.split():
        if word[0] in "aeiou":
            print word + "way"

        else:
            print word[1:] + word[0] + "ay"

What i did was ask for a sentence at the start and then i split it into words using the sent.split() function, then i could do the whole sentence at once rather then one word at a time.

how would i write the code for that?
sorry i'm a beginner i don't know what a sentance.split() function is...

sorry i'm a beginner i don't know what a sentance.split() function is...

Google is your friend. Or you can click here
Split() splits up (no way!) a string. If no argument is given (such as in the example by paulthom12345) it split the string up by whitespace. In English: It splits up your sentence in separate words :)

In line 7, you forgot to put a colon after 0. It should be word[0:]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.