+ 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 Respostas
+ 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!