79675920

Date: 2025-06-23 09:18:40
Score: 1
Natty:
Report link

I had a similar solution, but decided on creating a dictionary for the result. This works as well:

name_list = {}
input_str = input().strip().split()
name = input_str[0]
while name != '-1':
  try:
    age = int(input_str[1]) + 1  
    name_list[name] = age
  except ValueError:
    age = 0
    name_list[name] = age
  finally:        
    input_str = input().strip().split()
    name = input_str[0]
for k, v in name_list.items():    
  print(f'{k} {v}')  

This is the result:

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: mpasquali