0

Newb question, when I write:

def right_indent(s): print ' '*70+'s' #puts argument after 70 spaces right_indent('michael') s 

Why does it return s as a result? Shouldn't it be michael? This seems really simple but I have no idea what I'm doing wrong

1
  • 2
    Keep in mind 'print' and 'return' are two different things. Commented Mar 18, 2012 at 7:40

3 Answers 3

2

This is the name of the variable: s

This is what you put instead: 's'

A value enclosed in quotes is a string literal.

Sign up to request clarification or add additional context in comments.

Comments

2

There are quote marks around s, so it treats it as a literal string instead of as a variable name. Try:

print ' '*70+s 

You might be familiar with PHP, which happily translates variable names even if they're inside quotes. Python doesn't.

Comments

0

All of the previous answers are correct. I just thought that it might be important to mention that your function returns None (since it has no return ... statement). (try:

A=right_indent('michael') print A #Prints 'None' 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.