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
elif not len(original) < 0:
  print "empty"

look closely, notice that not len(original) < 0 has the same meaning as len(original) > 0 !
So really it should be: elif not len(original) > 0 in order to print “empty” ( do the other action) right guys?
help. thanks


no, there is no reason for elif statement, given there is no point. We want to inform the user about there wrong input in all cases, so we use else

using elif means that when original.isalpha() evaluate to false, but the length is greater then zero, we don’t inform the user of there invalid input


Oh i get it. But when i coded elif not len(original) > 0, it worked. Then i tried elif not len(original) < 0 that worked too! (I tested them by once entering a word with 0 characters and the other time entering a word which contains numbers). I don’t get why… In both situations, it printed ‘empty’. But why did that happen? According to you, it should only work with else: right?


no, the problem is that when you use elif instead of else, and we enter hello world, nothing happens, nothing gets printed at all, it should print empty

if we use else, it prints 'empty' as it should, although it would make more sense to inform the user that there input is 'invalid' instead of 'empty', not sure why the exercise opted for empty


Why does it happen? I mean it clearly has more than 0 letters and its all alphabetical. So its a valid ‘word’ right?
It should print original instead of empty! Am I right?


spaces are not alphabetic, so hello world is invalid, that is why printing invalid would be a better choice then printing empty


Hey thanks for your help. Now I understand it. I just have something else to know… actually its not from the 6/11 part, but its also Pyglatin:

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
  word = original.lower()
  first = word[0]
  new_word = word + first + pyg
  new_word =  new_word[1:len(new_word)]

Here, there are two new_words. If I code it to print new_word, how is python supposed to know what " new_word " I am talking about? What I am simply asking is, Is it okay for two variables to have the same name?



they are no two variables with the same name, its one variable, the value held by the variable simply gets re-assigned, so the value in the variable is the last assigned value


So its basically updating the value?


updating == re-assigning value stored in variable.


Got it. Thanks boss. Appreciate it. :wink: