Skip to content

Commit 51f3c1f

Browse files
committed
There is no 'raw_input' in Python 3
1 parent 01d092d commit 51f3c1f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tutorials/python.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ x = 8
8484
my_string = "Tall ship"
8585
~~~~~
8686

87-
You can ask the user to put some text into a variable with the `raw_input` function (we'll cover functions in more detail later):
87+
You can ask the user to put some text into a variable with the `input` function (we'll cover functions in more detail later):
8888

8989
~~~~~ python
90-
name = raw_input("What is your name?")
90+
name = input("What is your name?")
9191
~~~~~
9292

9393
[Concept: Identifiers](#concept-identifiers) {#concept-identifiers}
@@ -104,7 +104,7 @@ Exercises: Variables and Mathematics
104104

105105
### Average calculator ###
106106

107-
The first two lines of this program put two numbers entered by the user into variables `a` and `b`. (The `input` function is like `raw_input`, but returns a number (e.g. `42`) when you enter one, rather than a string (like `"42"`).) Replace the comment with code that averages the numbers and puts them in a variable called `average`.
107+
The first two lines of this program put two numbers entered by the user into variables `a` and `b`. (The `input` function is like `input`, but returns a number (e.g. `42`) when you enter one, rather than a string (like `"42"`).) Replace the comment with code that averages the numbers and puts them in a variable called `average`.
108108

109109
~~~~~ python
110110
a = input("Enter first number: ")
@@ -147,7 +147,7 @@ False
147147
`if` statements execute code only if their condition is true. The code to include in the `if` is denoted by a number of indented lines (see the concept section on [code blocks][block]). To indent a line, press the tab key or insert four spaces at the start. You can also include an `else` statement, which is executed if the condition is false. For example:
148148

149149
~~~~~ python
150-
name = raw_input("What is your name?")
150+
name = input("What is your name?")
151151
if name == "Tim":
152152
print("Hello Tim.")
153153
print("You've got an email.")
@@ -206,7 +206,7 @@ In most other programming languages, if you don't indent your code it will run j
206206
A group of consecutive statements that are all indented by the same distance is called a block. `if` statements, as well as functions and loops, all refer to the block that follows them, which must be indented further than that statement. An example is in order. Let's expand the first `if` example:
207207

208208
~~~~~ python
209-
name = raw_input("What is your name?")
209+
name = input("What is your name?")
210210
email = "Bank of Nigeria: Tax Refund"
211211
if name == "Tim":
212212
print("Hello Tim.")
@@ -387,17 +387,17 @@ Exercises: Lists and Loops
387387
Write a program which calculates the average of a list of numbers. You can specify the list in the code.
388388

389389
**Extension:**
390-
You can tell when a user has not entered anything at a `raw_input` prompt when it returns the empty string, `""`. Otherwise, it returns a string (like "42.5"), which you can turn into a number with the `float` function. For example:
390+
You can tell when a user has not entered anything at a `input` prompt when it returns the empty string, `""`. Otherwise, it returns a string (like "42.5"), which you can turn into a number with the `float` function. For example:
391391

392392
~~~~~ python
393-
var = raw_input("Enter a number: ")
393+
var = input("Enter a number: ")
394394
if var == "":
395395
print("You didn't enter anything!")
396396
else:
397397
print("You entered",float(var))
398398
~~~~~
399399

400-
Now, extend your program to let the user enter the list of values. Stop asking for new list entries when they do not enter anything at the `raw_input` prompt.
400+
Now, extend your program to let the user enter the list of values. Stop asking for new list entries when they do not enter anything at the `input` prompt.
401401

402402
### Fizz buzz ###
403403

0 commit comments

Comments
 (0)