I have a string in the following form :
"425x344"
Now I’d like to resolve first and second numbers from this string as two separate variables. How can I do this ? I’ve created this regex:
regex = re.compile(r"^(\d+x\d+)")
to check if the string form is proper. But what next ?
Since you’re filtering it with a regex, you can just do
If you’re planning on multiplying, it can be done in one line:
or
With an import and one line, this can be done with
You’ll have to profile them to see which is faster.