Jan-30-2019, 09:36 AM
Now when it's worked some alternative approach.
Just 'out'sane usage of f-strings :-)
Just 'out'sane usage of f-strings :-)
home = [input("Enter the home team's name: ")] visitors = [input("Enter the visiting team's name: ")] for i in range(1, 5): home.append(input(f'How many point did {home[0]} score in quarter {i}? ')) visitors.append(input(f'How many points did {visitors[0]} score in quarter {i}? ')) first, second, third = [f"<{len('Quarter')}s", f">{len(home[0]) + 2}s", f">{len(visitors[0]) + 2}s"] print('Total statistics') for i, row in enumerate(zip(home, visitors)): if i == 0: print(f"{'Quarter':{first}}{row[0]:{second}}{row[1]:{third}}") else: print(f"{str(i):{first}}{row[0]:{second}}{row[1]:{third}}") else: print(f"{'Total':{first}}{str(sum(int(x) for x in home[1:])):{second}}{str(sum(int(x) for x in visitors[1:])):{third}}")while using sample input it will give:
Output:Total statistics
Quarter Mountaineers Fighting Irish
1 7 7
2 10 7
3 0 14
4 21 0
Total 38 28
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.