【发布时间】:2020-09-06 04:50:14
【问题描述】:
我正在解决以下挑战,但自过去 4 小时以来现在无法这样做,我被卡住了:
挑战:
> Given a mathematical equation that has *,+,-,/, reverse it as follows:
>
> solve("100*b/y") = "y/b*100"
> solve("a+b-c/d*30") = "30*d/c-b+a"
我为解决挑战而编写的代码
def solve(s):
a,b = s.split('/')
return (b+"/"+a)
预期输出: 'y/b*100'
观察到的输出: 'y/100*b'
请您帮忙解决这个问题:
最好的问候, 迪瓦卡
【问题讨论】:
-
在
*上拆分a并反转结果。 -
Codewars 上的相关kata
标签: python python-3.6