"Framework Basics" was retired on December 6, 2017. You are now viewing the recommended replacement.

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

Python

How 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:

  1. Currently my code executes without a problem on desktop IDLE and works but outputs errors when ran within browser IDLE.

  2. Was there a better way to logically go about this?

  3. What could be improved?

Thank you!

Would you please put your code into proper syntax? Thanks :)

Steven Parker
Steven Parker
243,199 Points

What 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

your 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.