Check Yourself!


What is wrong with my code? it's not running after i added "else"

print 'Welcome to the Pig Latin Translator!'

Start coding here!

raw_input("What is your name?:")
original = raw_input('name')
if len(original) > 0 :
print str("original" + "name")
print "Empty"


This doesn't appear to be following instructions up to this point. If you are using an example from the lesson text for a model, then check the instructions for the intended usage and expected inputs. I don't think a name is the intended input, but a word. Any word. So rather than ask for a name, ask for a word.

The input is going to be a string, which means we would not need to convert using the str() function. That is not in the instructions, either so should be removed. Just print original.

>>> print (str("original" + "name"))

This shows that variables are never written in quotes, else they become plain string primitives. Strings do not refer to anything. Variables are pointers to a location in memory where a value or object is stored.

original = raw_input("Enter a word: ")

Somewhere in memory is that word, and original points to where it can be retrieved from.


thank you for your input and help :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.