Pyglatin 8/11


#1

I passed the 7/11 portion with this code, however it is saying the first letter is now stored.
pyg = ‘ay’

original = raw_input(‘Enter a word:’)

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

I have two questions concerning this:

  1. where is the number stored?
  2. if I enter a word when the code runs with a capitalized letter it still returns as capitalized, is that normal?

#2

the first letter is a letter, not a number. Its stored in first variable, which is quite a good variable name given it holds the first letter of word

well, your program converts it to lowercase, but it still prints original, which is not the variable containing the text which is converted to lowercase

this:

word = original
word = word.lower()

we can convert original to lower and store the returned result in word variable directly, so this could be a single line of code


#3

Thank you for this reply, it makes more sense now. If I’m understanding correctly we could condense

word = original
word = word.lower()

into something along the lines of

word = original.lower() ?


#4

yes. I might have lied a little. original stays intact, a copy of the string (converted to lowercase) is stored in word variable, we can see this:

original = "HELLO WORLD"
word = original.lower()
print original
print word

#5

Thank you for the clarification!


#6

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