+ 1
Input Validation
Iâm trying to write a block of code that will only accept floats, integers, and the letter âdâ. For some reason, the structure I have isnât working. Am I going about this the wrong way? Any help would be greatly appreciated. https://code.sololearn.com/c4SHeEEFvLpG/?ref=app
2 Answers
+ 3
Hi, try it changing it to this:
while True:
m = input('Please enter a measurement: ')
try:
data.append(float(m))
It seems to work.
+ 1
It works! Thank you!