我编写这个程序是为了能够从用户输入中找到 A/U 和 C/G 对的数量。当我运行它时,它一直说“无效的语法”,同时以红色突出显示 while 循环之后的第一个“else:”。有谁知道我需要改变什么来修复它?
def main():
first = input("Please enter the RNA sequence for which you wish to find the number of pairs. \nFirst line:")
second = input("Second String:")
a1base = first.count('A')
u1base = first.count('U')
c1base = first.count('C')
g1base = first.count('G')
a2base = second.count('A')
u2base = second.count('U')
c2base = second.count('C')
g2base = second.count('G')
while (a1base >= 1) and (u1base >= 1) or (a2base >= 1) and (u2base >= 1):
abases = (a1base+ a2base)
ubases = (u1base + u2base)
firstset = min(abases, ubases)
print("You have", firstset,"A/U bases.")
else:
print("You have zero A/U bases.")
while (c1base >= 1) and (g1base >= 1) or (c2base >= 1) and (g2base >= 1):
cbases = (c1base + c2base)
gbases = (g1base + g2base)
secondset = min(cbases, gbases)
print("You have", secondset,"C/G bases.")
else:
print("You have zero C/G bases.")
main()