"5. Check Yourself....Some more!" what?


#1



It tells me to put in "has_chars" then I go to enter in the code the console tells me "has_chars" is not defined.

Error Message: Traceback (most recent call last):
File "python", line 12, in
NameError: name 'has_chars' is not defined


print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word")
print original

if len(original) > 0:
    print original
else:
    print "empty"
    
if has_chars(the_string) and the_string.isalpha():
    print the_string
else:
    print "empty"


#2

We can tell if a string has characters if the length is greater than zero.


#3

Oh! That's what I'm missing! Thank you!


#4

Never mind it's not working the way I intended. Here's My updated code

print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word")
print original

if len(original) > 0:
print original
else:
print "empty"

if has_chars(the_string) > 0 and the_string.isalpha():
print the_string
else:
print "empty"


#5

All superfluous. Work with the earlier lines above it.

original = raw_input("Enter a word")
# validate here
    print original
else:
    print "empty"

Validation

len(original) > 0 and original.isalpha()

#6

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