Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Benji Beck
5,238 PointsHow do we convert strings in python?
Goal: Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take:
Ask the user to input a word in English. Make sure the user entered a valid word. Convert the word from English to Pig Latin. Display the translation result.
Current code: print("PigLatin Translator Beta") print("What word would you like to translate ? ") user = input() translated = user[1:] + user[0] + "ay" print(translated)
Questions:
Currently my code executes without a problem on desktop IDLE and works but outputs errors when ran within browser IDLE.
Was there a better way to logically go about this?
What could be improved?
Thank you!
Steven Parker
243,199 PointsWhat kind of error are you getting?
When you say "browser IDLE", do you mean the workspace? If so, you can make a snapshot of your workspace and post the link to it here for analysis.
1 Answer
cb123
Courses Plus Student 9,858 Pointsyour approach was essentially correct. And worked fine in workspaces if i put in the proper carriage returns.
print("PigLatin Translator Beta")
user = input("What word would you like to translate? ")
translated = user[1:] + user[0] + "ay"
print(translated)
A slight tweak for fewer lines of code, but changes where the input prompt entry occurs, so you may not want that..
I can't speak to your "IDLE" issue.
nakalkucing
12,964 Pointsnakalkucing
12,964 PointsWould you please put your code into proper syntax? Thanks :)