Complex Numbers

Published by TheDuckOne78 in

Write a function that takes a string "a + bi" and returns a tuple (a, b).

Examples

complex_to_tuple("1 + 2i") ➞ (1, 2)

complex_to_tuple("6 + 9i") ➞ (6, 9)

complex_to_tuple("-7 - 2i") ➞ (-7, -2)

Notes

All strings are going to have the (±)a ± bi format, (where a and b are integers).

Watch a quick demo on how Edabit works.