Python全RE求助
查看原帖
Python全RE求助
1170071
Operation0701楼主2023/11/11 01:22
def match(s,k):
    cnt,i = 1,0
    a, b = 0, 0
    for s in line:
        while i < len(s):
            if s[i] == 'E':
                return a,b
            if s[i] == 'W':
                a += 1
            else:
                b += 1
            if cnt % k == 0 and cnt != 0:
                print(f'{a}:{b}')
                a, b = 0, 0
            cnt += 1
            i += 1
        i = 0
        if cnt % k != 0:
            cnt = cnt % k

line = []
while True:
    s = input()
    line.append(s)
    if s[-1] == 'E':
        break

a,b = match(line, 11)
print(f'{a}:{b}')
print('')
a,b = match(line, 21)
print(f'{a}:{b}')

不知道为啥全部RE,自己在pycharm上运行没问题

2023/11/11 01:22
加载中...