mardi 5 février 2019

Python function that checks value of a string

Write a function is_nneg_float() that checks if string s denotes a non- negative floating point value (not in scientific notation). This function should return True if s contains (at most) one decimal point and one or more digits (and nothing else); and False otherwise. According to this definition an integer should return True.

I have no idea how to solve this, i feel like i first have to convert the string to a float and then maybe compare the rounded number to the original number ? i don't know

Aucun commentaire:

Enregistrer un commentaire