Search code examples
pythonvariablespython-2.7variable-assignmentraw-input

Using raw_input() without assigning a variable


I've only recently begun learning python2, and this is the way I see raw_input().

If suppose I write name = raw_input("What's your name? ") then I ask the user to enter something which gets stored as a string assigned to the variable name. By assigning it to name, I can use it for whatever purpose I needed it later.

But what does using raw_input() without assigning the input to a variable accomplish? Also pressing enter at this point is supposed to continue with the script (so I have deduced, am I right?), but where is this behaviour documented? In what kind of a situation would I use raw_input() without assigning to a variable? I couldn't find my answers in the official python documentation. http://docs.python.org/2/library/functions.html#raw_input

THanks


Solution

  • For debugging purposes you may just want your code to pause for a second so you can analyse some print statements describing what's happening in your code. There's really not set reason for having this, it's up to you.