Advertisement
go6odn28

01. Extract Person Information

Mar 16th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. n = int(input())
  2. name = ""
  3. age = ""
  4. for sentences in range(n):
  5.     text = input()
  6.  
  7.     start_index_name = text.index('@') + 1
  8.     end_index_name = text.index('|')
  9.     start_index_age = text.index('#') + 1
  10.     end_index_age = text.index('*')
  11.  
  12.     name = text[start_index_name:end_index_name]
  13.     age = text[start_index_age:end_index_age]
  14.  
  15.     print(f"{name} is {age} years old.")
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement