Advertisement
Faiakes

Debugging

Jun 15th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. 1. colon missing, line 5
  2. 2. range length should be 5
  3. 3. age variable syntax should be: ages[person]
  4. 4. year_of_birth variable calculation should be the other way round: current_year - age
  5. 5. 'name' in output shoube just: name
  6. 6. year_of_birth in output needs to be converted to string
  7.  
  8. The code:
  9. -----------------------
  10. import datetime
  11.  
  12. names = ['Alice', 'Bob', 'Carol', 'Dan', 'Eve']
  13. ages = [22, 32, 18, 57, 41]
  14. c_year= datetime.datetime.now().year
  15.  
  16. for person in range(5):
  17.     age = ages[person]
  18.     name = names[person]
  19.     year_of_birth = c_year - age
  20.     print(name + ' was born in ' + str(year_of_birth))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement