Pyglatin


#1

Hi everyone,

On the Pyglatin exercise of the Conditionals and control flows section, I don’t understand why the .isalpha function is not equaled to TRUE in the conditioning.

How I would have coded it :

print ‘Welcome to the Pig Latin Translator!’

Start coding here!

original = raw_input(“Enter a word:”)
if len(original) > 0 and original.isalpha() = true :
print original
else:
print “empty”

How Codeacademy coded it :

print ‘Welcome to the Pig Latin Translator!’

Start coding here!

original = raw_input(“Enter a word:”)
if len(original) > 0 and original.isalpha():
print original
else:
print “empty”

I would have thought that we needed to format it to TRUE in order to validate the word.

Thanxs in advance for your help !


#2

no, its not needed. You don’t have to do a comparison. For example you could just do:

if True:

or:

if False:

comparison isn’t mandatory, you can simple see if something evaluate to true or false.

if you do want a comparison, don’t forget that = means assign while == means check if equal


#3

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