Why was I supposed to type pyg in this exercise?


#1

Inside your if statement:

Create a new variable called word that holds the .lower()-case conversion of original.
Create a new variable called first that holds word[0], the first letter of word.

pyg = 'ay'
word = original.lower
original = raw_input('Enter a word:')
first = word [0]

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

the exercise

What exactly am I suppose to do for this exercise? Declare the variable inside the if statement?


#2

nevermind I saw that you can declare a variable inside an if statement. did not know that.

Here is the working code:

pyg = 'ay'///why pyg?

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
  word = original.lower()
  print word
  first = word[0]
else:
    print 'empty'

#3

Hi @jacquesk,

Haha, there doesn’t seem to be a reason outside of the Codecademy people wanting to be punny.
Pig Latin ==> Python (.py) ==> pyg

Variables can be named anything you want but are expected to follow certain conventions (PEP 8 - Style Guide)

Hope this helps! :smile:


#4

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