Stuck on 8.Word Up for 2days, Please help


#1

This is my code. And the error I keep getting states: File "python", line 13
else:
^
SyntaxError: invalid syntax
What am I doing wrong? Please someone help me get through this.

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]
print first
else:
print 'empty'


#2

can you repost your code with the right indent or a screenshot
if you want to format your code when you paste it here you have three options

  1. select the code (after you paste it here) and press ctrl + k or
  2. select the code(after you paste it here) and press </> in the tools pane
  3. put this character ` three times at the begining and end of code

#3


#4

Hi, I just completed the exercise 8 but I do not quite understand how the code works.

What I currently understand:

We created a new variable called word and that it was equal to the lowercase version of original. This means that if we typed in "Python" for original. It would "hold?" the lowercase version of original. After that we created another new variable called first and it "holds?" the word[0], which would be the first letter of Python.

What does it mean that it "holds" something when we are talking about word[0]?


#5

Whenever I try to do the code, it says:
File "python", line 11
else:
^
SyntaxError: invalid syntax

And then it says on the bottom.

Oops, try again. Did you create a variable called word?

Please help me.


#6

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'


#7

That is exactly the same issue I am running into.
It's been about four days now and I still can't figure it out.


#8

On the hints section it says...

Use a variable called word to store the result of original.lower().
Use a variable called first to store the result of word[0]

So, to create a variable called word which stores the data of original.lower(), you would simply do...

word = original.lower()

#9

line 7,8,9,10 , no indentation


#10

`indent preformatted text by 4 spaces
I tried the following:

pyg = 'ay'

original = raw_input('Enter a word:')

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

I get an error from the console:
Enter a word: car
Traceback (most recent call last):
File "python", line 6, in
NameError: name 'orignal' is not defined


#11

ok, code was ok except for a spelling mistake on original line: word = original.lower()