-2
import re
for test in range(int(input())):
a = input() # input a string
n = a.replace("=", "") # if string contains '='then remove it
gg = re.findall(r ">+", n) # count >
l1 = len(max(gg, key = len)) # count consecutive >
hh = re.findall(r "<+", n) # count <
l2 = len(max(hh, key = len)) # count consecutive <
print(max(l1, l2) + 1) # print max of two + 1
输入是:
< < <
< > <
< =>
< = <
我遇到错误,如果我运行上述code.I上阅读SO只有语法仍然我得到错误:re.findall()的代码中有什么错误?
Traceback (most recent call last):<br/> File "/home/fea0d5e04ac92cb3a1e4f041940f2dfc.py", line 8, in <module><br/> l2=len(max(hh, key=len))<br/> ValueError: max() arg is an empty sequence
请包括你得到的错误。当我运行代码时,它工作正常。 – user3080953
@ user3080953编辑它 – user8539458
您的意见是什么? –