Word up


#1



Seem to be having some difficulty getting this code to work.

It's not returning a lower case entry in the console, but codecademy is acknowledging exercise complete ?

I've tried refreshing the page a couple of times and moving around the new variables of word and first to no luck.

The only time i could get the code to work was when i changed the 'word' variable to 'original'. This would then return lower case. However, i would then get an error message.

Further side note, i also receive an error message when entering numbers. This was covered in a previous exercise, now it seems like its missing


https://www.codecademy.com/en/courses/python-beginner-2W5v7/1/2?curriculum_id=4f89dab3d788890003000096#


pyg = 'ay'

original = raw_input('Enter a word:')

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


#2

Hi @textmaster96582,

There are 2 things I want to point out here.

  1. Where you position your print statement

As you can see, you actually printed the word first before you manipulated it to become entirely lowercase. I think it is good habit to note that Python reads the code in order, so actually you should shift your print statement down, making sure it comes after the word = original.lower() bit.

2.What you eventually print

If you do print original, you notice that it returns the word you keyed in, without becoming lowercase. However, if you do print word, you notice that it returns the correct lowercase-d word. This is because when you made original lowercase, you stored this lowercase-d form under the variable name word, such that word is now original in lowercase (aka whatever you input in lowercase), while original remains (no pun intended) the original word which you typed in, uppercase and all.

Hope this helps :slight_smile:


#3

thanks for the reply ! well explained, helped fix the code and my understanding of python :slight_smile:


#4

@textmaster96582,

Glad to be able to help :slight_smile:

To indicate that this question has been solved, just click on the small checkbox icon below my previous answer, so that others will also know that this issue has been resolved.