PygLatin part 2


What are they asking with the Word Up exercise?

Nothing was explained about this


'word up' would imply user input, perhaps?


Below it was never explained to me:

Where to create a variable int he if statement
How to store the result of the variable

Use a variable called word to store the result of original.lower().

Use a variable called first to store the result of word[0].

And make sure that you do this inside your if statement.

Note: You can print out the values of the variables word and first to double-check your work (remove these print statements when you're done debugging).

Remember that the first letter of a string can be found at index 0, like this:

Here is my code

pyg = 'ay'

original = raw_input('Enter a word:')

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


This is a practice exercise so should not contain too many new concepts.

Both of the above assignments are correct. The input is stored in original so it will now reference the word entered.

Two conditions are tested in the if statement. Length and valid characters.


must be greater than 0 otherwise it is an empty string, not a word.


must not contain any non-alphabetical (letter) characters.

original is an instance of the String class, so inherits the method, .isalpha() which is built into the class.

As the instructions ask, this should be another assignment:

word = original.lower()

The above preserves the original input, but copies a lowercase version to word.

first = word[0]

The wording is a bit awkward. This is not a result, but the first letter of the word. [0] is the index subscript pointing to index zero, the first character position in a string.

Again, it doesn't mention this, but you can replace,

print original

with your new code. Leave the else clause at the bottom.


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