You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read a line of text from standard input and return the equivalent char;
76
-
if text is not a single char, user is prompted to retry. If line can't
77
-
be read, return None.
78
-
"""
79
-
whileTrue:
80
-
s=get_string(prompt)
81
-
ifsisNone:
82
-
returnNone
83
-
iflen(s) ==1:
84
-
returns[0]
85
-
86
-
# Temporarily here for backwards compatibility
87
-
ifpromptisNone:
88
-
print("Retry: ", end="")
66
+
raiseNotImplementedError("The CS50 Library for Python no longer supports get_char (because Python doesn't have a type for individual characters), but you can use get_string instead!")
89
67
90
68
91
-
defget_float(prompt=None):
69
+
defget_float(prompt):
92
70
"""
93
71
Read a line of text from standard input and return the equivalent float
94
72
as precisely as possible; if text does not represent a double, user is
@@ -104,12 +82,8 @@ def get_float(prompt=None):
104
82
exceptValueError:
105
83
pass
106
84
107
-
# Temporarily here for backwards compatibility
108
-
ifpromptisNone:
109
-
print("Retry: ", end="")
110
85
111
-
112
-
defget_int(prompt=None):
86
+
defget_int(prompt):
113
87
"""
114
88
Read a line of text from standard input and return the equivalent int;
115
89
if text does not represent an int, user is prompted to retry. If line
@@ -127,34 +101,8 @@ def get_int(prompt=None):
127
101
exceptValueError:
128
102
pass
129
103
130
-
# Temporarily here for backwards compatibility
131
-
ifpromptisNone:
132
-
print("Retry: ", end="")
133
-
134
-
135
-
ifsys.version_info.major!=3:
136
-
defget_long(prompt=None):
137
-
"""
138
-
Read a line of text from standard input and return the equivalent long;
139
-
if text does not represent a long, user is prompted to retry. If line
140
-
can't be read, return None.
141
-
"""
142
-
whileTrue:
143
-
s=get_string(prompt)
144
-
ifsisNone:
145
-
returnNone
146
-
ifre.search(r"^[+-]?\d+$", s):
147
-
try:
148
-
returnlong(s, 10)
149
-
exceptValueError:
150
-
pass
151
-
152
-
# Temporarily here for backwards compatibility
153
-
ifpromptisNone:
154
-
print("Retry: ", end="")
155
-
156
-
157
-
defget_string(prompt=None):
104
+
105
+
defget_string(prompt):
158
106
"""
159
107
Read a line of text from standard input and return it as a string,
160
108
sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n)
0 commit comments