How can I convert the user input go 30,45 to go(30,45)?
so far I have:
input = "go 30,45"
output = re.sub(r'go (\d+)', r'go(\1,\1)', input)
However this doesn’t seem to be working, I know it is probably down to the (\1,\1) but what could I change to get the desired output?
Thanks
Try this:
Note that you should refrain from using
inputas a variable name since it is already reserved.