Input Validation | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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

24th Apr 2018, 5:20 AM
Michael Godfrey
Michael Godfrey - avatar
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.
24th Apr 2018, 6:26 AM
Paul
Paul - avatar
+ 1
It works! Thank you!
24th Apr 2018, 7:29 AM
Michael Godfrey
Michael Godfrey - avatar