PygLatin: I don´t really get how .isalpha() actually works!


#1

https://www.codecademy.com/courses/learn-python/lessons/pyglatin/exercises/check-yourself-some-more?action=lesson_resume&link_content_target=interstitial_lesson

Hi everybody, thanks for attending.

I supose this code to show me “empty” as an uotput if the string entered by the user has any non-alphabetical character. If the input just contains letters I should get the string printted.

The thing is that even if the string has any numerical character the code stills prints both the “string” and the “empty” outputs, and that shouldn’t happen since the conditional is working properly.

This is the code I’ve written, please check it out and tell me if you find the mistake.

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

if len(original) > 0 and original.isalpha():
print original

else:
print “empty”


#2

There should only be one print original statement, in the if statement.


#3

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