Posts by Pedro Bernardo • 121 points
6 posts
-
-3
votes1
answer895
viewsQ: How to traverse the string by words or by letters?
Code: while True: regras, numero_frases = map(int, input().split()) if regras == 0 and numero_frases == 0: break dici = {} for r in range(regras): subs = input().replace(' ', '').split('->')…
-
0
votes1
answer32
viewsQ: How to make the program recognize a name with spaces next to a float?
Code: compras = {} soma = 0 while True: dados = input().split() if dados[0] == '*': break else: compras[dados[0]] = float(dados[1]) while True: comandos = input().split() if comandos[0] == 'total':…
-
1
votes1
answer44
viewsQ: How can I check if an element of a list that corresponds to the value of a dictionary is related to the key?
Code: entrada = '' dici_presentes = {} listavalores = [] while entrada != 'FIM': casos = int(input()) for i in range(casos): nome_presente = input().split() c = nome_presente[0] v =…
-
0
votes1
answer48
viewsQ: How do you know if the phrase is on the list?
I want the message "Uhul! Your secret friend will love", but the variable present always gives as answer "Try Again", example: in the variable 'personal gifts' I type 'pedro camisa keyboard chair',…
-
0
votes0
answers150
viewsQ: How to solve the "Exceeded Time Limit" in this code?
Input format : The input consists of a series of pairs of integers i and j, a pair of integers per line. All integers will be less than 1,000,000 and greater than 0. Note that the entry only ends…
-
5
votes2
answers328
viewsQ: Print multiple numbers with a separator between them, but do not put the separator after the last
Make a program that reads two integers, representing the start and end values of a range and print the multiples of 5 between them. My code: valores = input().split() numero1 = int(valores[0])…