Reputation: 2016
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
Upvotes: 0
Views: 57
Reputation: 309841
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'
Upvotes: 0
Reputation: 76695
This is the name of the variable: s
This is what you put instead: 's'
A value enclosed in quotes is a string literal.
Upvotes: 2
Reputation: 4868
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.
Upvotes: 2