bash - check for string to be list of integers separated by + signs in python -
I want to see that the mivar be divided by Then I realized that it would still work for the wrong cases such as: Use a regex free alternative partition: < em> returns: more than one integer + . Should it be
re.search () enough?
myvar = "1 + 2 + 3" if (re-search (r "^ [0- 9] + (\ + [0-9] +) * $", miver) : "Print" should be an integer integer (% s) "% myvar sys.exit (1)
myvar = "1 + 2 + 3-4"
myvars = ["+1", "1 + 2 + 2", "1 + 5", "1 + 2 + 3 "] for myvars in hevor: nums = myvar.split ('+') for num: num: try: int (num): print" error ", myover
error +1 error 1++ 2
Comments
Post a Comment