Skip to content

Commit 6ac96f8

Browse files
authored
Update number_input_examples.py
1 parent eacf487 commit 6ac96f8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

number_input_examples.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# number_input_examples.py
22

3-
# This file accompanies the Real Python article "How To Read User Input As Integers".
4-
# It contains examples of functions that filter user input for valid integers and floats.
3+
# This file accompanies the Real Python article
4+
# "How To Read User Input As Integers". It contains
5+
# examples of functions that filter user input for
6+
# valid integers and floats.
57

68

79
def get_integer(prompt: str, error_message: str = None) -> int:
@@ -50,12 +52,16 @@ def get_integer_with_default(
5052

5153
if __name__ == "__main__":
5254
print(get_integer("Testing get_integer(): "))
53-
print(
54-
get_integer("Testing get_integer() with an error message: ", "Invalid integer!")
55+
print(get_integer(
56+
"Testing get_integer() with an error message: ",
57+
"Invalid integer!")
5558
)
56-
print(get_float("Testing get_float() with an error message: ", "Invalid float!"))
59+
print(get_float
60+
("Testing get_float() with an error message: ",
61+
"Invalid float!"))
5762
print(
5863
get_integer_with_default(
59-
"Testing get_integer_with_default(): ", 99, "That's not a valid integer!"
64+
"Testing get_integer_with_default(): ",
65+
99, "That's not a valid integer!"
6066
)
6167
)

0 commit comments

Comments
 (0)