Reputation: 1011
I can solve it using multiple ifs and right function... but was wondering if there were a nicer solution...
as an example
10,5 would return true
10 would return true
9,3 would return false
9,5 would return true
Any ideas?
Upvotes: 0
Views: 65
Reputation: 16499
Use regex:
import re
def int_or_comma_5(n):
return re.match('\d+(,5)?$',n)
Upvotes: 2