Python - Indentation Error

Hello all -

Long shot, but I am having a heck of a time figuring out what I am doing wrong here. Any help would be greatly appreciated.


In this program, you must ask the user:

“What is your name?”

And then respond by printing out a personalized greeting.


For a person named Maria, respond by printing:

Hello Maria :slight_smile:

For a person named Wally, respond by printing:

Hello Wally :slight_smile:


In general, for a person named , respond by printing:



Two people are special: Amar and Brandy.

A person named Amar or Brandy should receive an additional comment after you say hello

For a person named Amar, respond by saying:

Hello Amar :slight_smile:

I like your shoes

For a person named Brandy, respond by saying:

Hello Brandy :slight_smile:

You seem like a cool person

Note that the robot grader will only mark your solution correct if your

print statements match EXACTLY what was specified above.

Spelling, spacing, punctuation… all that stuff matters.

Your input statement also matters. You must say it exactly like this:

What is your name?

Here is what I have so far, and I am getting an indentation error:

Put your Python code here:
name = input(“What is your name?”)
print(“Hello” ,name,":)")
for name in[“Brandy”]:
print(“you seem like a cool person”)
for name in[“Amar”]:
print(“I like your shoes”)


For each number between 1 and 100…

If the number is odd, then simply print it out.

BUT if the number is even, then print the word “Steven” instead.

When I run your program, I should see the following output:










Note that you shold start at 1 (not 0), and that the 100 must be INCLUDED.

In other words, the last number should be 100, not 99.


Thanks so much for your feedback!

For the first one, the code should look something like this:

Second one like this:

1 Like

The second one can be simplified as follows (Python3):

for count in range(1,101):
  print(count if count&1 else "Steven")
1 Like

That’s nice. I changed mine to reflect a more spelled out version of yours.

1 Like

Python is my favorite language outside of Ruby.

Thanks for you help!
It didn’t quite work though. It is for Python 2.

Which version of Python 2?

It is for version 2.7

Just remove the parenthesis on the print statements:

When I run my solution on Python 2.7 it works for me. Can you post a screen shot of what you get on Python 2.7?

For the first one you’ll have to have raw_input instead of input:

It worked.
Thank you!!

Oh the 1st one. I thought you meant the second one. If you want a more optimized version (specifically for Python 2.7) of the 2nd one that I wrote above then the following is more efficient:

for count in xrange(1,101):
  print count if count&1 else "Steven"

Note 1: You can actually use the parentheses or not for print in Python 2.7

Note 2: xrange is more efficient than range in Python 2.7. In Python 3, range is the equivalent of xrange of 2.7

There are several key differences between the two versions of Python which you need to be aware. A web search will yield these differences.

1 Like