anonymous
  • anonymous
Does anyone else get an error message when using this in idle? The example is giving in the reading assignment but it doesn't work and I'm not understanding why. I get the error message when I enter: plusTen = number + 10 print ("Please give me a number:",) response = raw_input() number = int(response) plusTen = number + 10 print ("If we add 10 to your number, we get " + str(plusTen))
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
nowhereman
  • nowhereman
Observe that there is a different syntax for print in python-2 and python-3. Also the user-input in your case must be a legal number. If you enter "plusTen = number + 10" that is not a number and an exception is thrown. You should catch that in the code.
anonymous
  • anonymous
i understand the "type" error. the reading says that to fix it you need to use 'int' and 'str'. the modified example in the reading gives me the error message, though, it does not work with the fixes it recommends.
nowhereman
  • nowhereman
As long as you don't input anything which can be converted to an integer, you will get an error.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

carlsmith
  • carlsmith
It's a bit odd to be printing a tuple as a prompt before an input function call? For Python2, it'd be a little more sane to do: response = raw_input('Please give me a number: ') number = int(response) # will crash if this conversion isn't doable plusTen = number + 10 print 'If we add ten to your number, we get ' + str(plusTen) For Python3: response = input('Please give me a number: ') number = int(response) # can crash still plusTen = number + 10 print('If we add ten to your number, we get', plusTen) Dunno if that helps at all.

Looking for something else?

Not the answer you are looking for? Search for more explanations.