Original Name is still coming up


#1



PygLatin - Check Yourself...More


Code is returning original name, when non-alpha is entered


"empty" should come up instead


print 'Welcome to the Pig Latin Translator!'

# Start coding here!
name = raw_input("What's your name?")
print name
original = name
if len(original) > 0 and original.isalpha():
    print name
else:
    print "Empty"


#2

Hey there!
It's a simple mistake.
Just replace...

print name

with...

print original

And also, you might as well want to remove the "print name" on line 6. (After the raw_input)


#3

Code is returning original name, when non-alpha is entered

Let's say that user inputs 812, he will get this output:

812
Empty

The first line of output is caused by the first print name (line 5). If you don't want to print the name just delete this statement.


Variables name and original holds exactly the same value, that is why @ronybot suggestion does not make much sense. You only need one:

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
name = raw_input("What's your name?")
if len(name) > 0 and name.isalpha():
    print name
else:
    print "Empty"

#4

Or yes you could do that instead, makes more sense :grin:

My bad.


#5

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