Skip to content

Commit a717587

Browse files
committed
Fix confused usage of input in the Python tutorial
From the context it looks like this was previously comparing Python 2's `raw_input` and `input` functions, and that this was missed during the upgrade to Python 3. Drop the comparison and explicitly parse the inputs to numbers to let the reader focus on the task at hand (computing the average). Fixes #533
1 parent d17de1f commit a717587

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tutorials/python.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ Exercises: Variables and Mathematics
112112

113113
### Average calculator ###
114114

115-
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`.
115+
The first two lines of this program put two numbers entered by the user into variables `a` and `b`.
116+
Replace the comment with code that averages the numbers and puts them in a variable called `average`.
116117

117118
~~~~~ python
118-
a = input("Enter first number: ")
119-
b = input("Enter second number: ")
119+
a = float(input("Enter first number: "))
120+
b = float(input("Enter second number: "))
120121

121122
# Store the average of a and b in the variable `average`
122123

0 commit comments

Comments
 (0)