Using procedures

I'm having an issue with this section.

I am trying to enter the information into my Python 3.2 shell, because I cannot type anything in the simulator onscreen. So far I've had no issue with following along this way, but now that I'm trying to do the following as the instructor has done, I keep getting error messages when I try to print.

def rest_of_string(s):
    return s[1:]

print rest_of_string('audacity')

Please help!

asked 16 Mar '12, 19:23

Brownbunny05's gravatar image

Brownbunny05
112
accept rate: 0%

edited 16 Mar '12, 19:31

Graeme's gravatar image

Graeme
5.9k214895

I formatted your code. See this thread for more info:

http://www.udacity-forums.com/cs101/questions/16591/protip-how-to-format-your-code-properly-for-the-forums

You'll run into trouble using Python 3 for this course. But if you want to fiddle around with it online, here's an interpreter: http://ideone.com

(16 Mar '12, 19:33) Graeme Graeme's gravatar image

As an aside, you might be able to get the online class interpreter working for you if you switch browsers. I think both Firefox and Chrome are supported on all platforms; I know there are issues with at least some versions of Internet Explorer.

(16 Mar '12, 19:52) Lisa McLean Lisa%20McLean's gravatar image

One Answer:

print is now a function in python 3. You need to print inside quotes parentheses. It would be:

print (rest_of_string('audacity'))

The new print syntax is

print('a string')

or

foo = "string"
print(foo)
link

answered 16 Mar '12, 19:29

Graeme's gravatar image

Graeme
5.9k214895

edited 16 Mar '12, 19:49

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,886
×32
×10
×6
×2

Asked: 16 Mar '12, 19:23

Seen: 178 times

Last updated: 16 Mar '12, 19:52