9/11 Move it on Back


#1

9/11 Move it on Back

It said my code wasn’t correct. I would like to know what happened.

original = raw_input(‘Enter a word:’)

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

Please help.


#2

what is pyg ?
where does it come from?


#3

Sorry I forgot to add the first line.There’s a variable defined at the beginning

pyg = ‘ay’


#4

I’m having the same issue with the exact same code. I have no idea why it’s being viewed as incorrect.


#5

So the problem here is the the solution to the exercise contains a wrong indentation.
According to the author this is the correct answer:

Which shouldn’t be correct as lines 5 and 9 should not be indented.
It looks like the colon ‘:’ in ‘Enter a word:’ is confusing the compiler into giving a error.


#6

@claretta, I don’t think that’s the issue, as I was able to get it to pass using standard indentation:


#7

Hi, thanks for your feedback! The only difference I see between your screenshot and mine is the indentation of the variables line 6-7-8 (yours start below right below len(), while mine begins a bit further on the left). I think it would be of great help if the console could render where all the indentation errors occur, because it often doesn’t and the whole exercise crashes :frowning:


#8

In python, a standard indent is 4 spaces. Therefore, the only difference is the indentation levels in the if and else statements (lines 5 and 9 respectively). Your screenshot shows those two lines having whitespace before them (improper indentation), whereas mine does not.


#9

Indeed, and my point is that the screenshot posted above is what the exercise gives you as a solution once you hit the “Get code” button; and this contains improper indentation. This is why I think lots of users get stuck.


#10

If this is the case, then I would recommend submitting a bug-report.


#11

Yup, I did so. And I hope they will somehow improve the way indentation errors show up in the console. Cheers :wink:


#12

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