1 Replies - 1822 Views - Last Post: 05 March 2010 - 04:45 AM Rate Topic: -----

#1 Guest_Gretty*


Reputation:

Can Python take User input

Posted 05 March 2010 - 01:08 AM

Ok this is probably a really dumb question but I have searched for tutorials on this.

Can python take user input; like for example in c++ if I want the user to enter a number I use:
cin >> x;

Can Python do this also? How do I do it?
Is This A Good Question/Topic? 0

Replies To: Can Python take User input

#2 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: Can Python take User input

Posted 05 March 2010 - 04:45 AM

In Python 2.*, you can use the raw_input (which will get any String, then just convert to an integer. In Python 3.*, just use input() and convert:

# Python 2.6
input = int(raw_input("text prompt > ")


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1