Advertisement
von_mises

Cadastro de jogadores de futebol automático-dicionário-v2.0

May 19th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. time = list()
  2. partidas = list()
  3. jogador = dict()
  4.  
  5. while True:
  6.     print("-=-"*25)
  7.     jogador['nome'] = str(input("Nome do jogador: "))
  8.     tot = int(input(f"Quantas partidas o {jogador['nome']} jogou? "))
  9.     partidas.clear()
  10.     for a in range(0, tot):
  11.         partidas.append(int(input(f"     Quantos gols na partida {a+1}? ")))
  12.     jogador['gols'] = partidas[:]
  13.     jogador['total'] = sum(partidas)
  14.     time.append(jogador.copy())
  15.     while True:
  16.         resp = str(input("Quer continuar?[S/N]")).upper()
  17.         if resp in "SsNn":
  18.             break
  19.         print("ERRO! Responda apenas S ou N.")
  20.     if resp in "Nn":
  21.         break
  22.  
  23. print("-=-"*40)
  24. print("cod", end = ' ')
  25. for i in jogador.keys():
  26.     print(f"{i:<15}", end = ' ')
  27. print("")
  28. for b, c in enumerate(time):
  29.     print(f"{b:>3}", end = ' ')
  30.     for d in c.values():
  31.         print(f"{str(d):<15}", end = ' ')
  32.     print()
  33. print("-=-"*40)
  34. while True:
  35.     busca = int(input("Mostrar dados de qual jogador?(999 para parar) "))
  36.     if busca == 999:
  37.         break
  38.     if busca >= len(time):
  39.         print(f"ERRO!! Não existe jogador com o códito {busca}")
  40.     else:
  41.         print(f" -- LEVANTAMENTO DO JOGADOR {time[busca]['nome']}: ")
  42.         for i, g in enumerate(time[busca]['gols']):
  43.             print(f"    No jogo {i+1} fez {g} gols.")
  44. print("<<<<< FIM DO CÓDIGO >>>>>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement