anonymous
  • anonymous
Can we use 'input' instead of 'raw_input', I tried 2.6 and 3.3 versions and 'input' seems to work on both. Just a thought
MIT 6.00 Intro Computer Science (OCW)
  • 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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Of course you can. The only difference is that by using raw_input you are always getting a string value as an input which you must convert/cast to the required type. Also, I believe that raw_input does not exist in Python v3.x. It has been renamed to input(). The following are true for Python v2.x. On the other hand input will evaluate whatever you pass in. So if you pass in a number (and the input function can understand that it is a number) you will get an int value back, where with raw_input you would get a string representation of the int value. Therefore, if you pass the number 3 to input function, you will get back the int 3. If you pass the same value to raw_input, you will get back the string '3'. In order to get the integer value of it, you can do int(raw_input('give me an integer: ')) In general I would suggest you use raw_input!
anonymous
  • anonymous
But, if you are using Python3.3 raw_input generates an error
anonymous
  • anonymous
Yes cause it doesn't exist. It has been replaced by input() function!

Looking for something else?

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

More answers

anonymous
  • anonymous
OK Thanks
anonymous
  • anonymous
No problem at all!
MicroBot
  • MicroBot
@Chris2332 you siad that in general you would suggest raw_input over input...why? i mean input basically (as i understand )recognises whatever u type....why should i use a func that sees everything as a string unless i tell it to see it as smthing else?
anonymous
  • anonymous
I was thinking something along those lines, if 3.3 only has 'input' and it recognizes everything as is, then surely, as someone new to Python I should use that ?
rsmith6559
  • rsmith6559
In Python2.x raw_input works like input does in Python3.x. 2.x is a different thing altogether.
anonymous
  • anonymous
@MicroBot I would suggest raw_input so you are always certain that the function always returns a string and then you manipulate it the way you want. So you cast it as you see fit or use it any way you might want. The control is yours effectively

Looking for something else?

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