0

Question:

Write a function nth_item(data, n) that takes a list data and an integer n as parameters and returns the nth item of the list of data, assuming the first item has an index of n = 0. You may assume that data contains at least n + 1 items.

I can get the right item from the list but always followed by "None". Not sure why "None" keeps appearing or where i'm going wrong.

def nth_item(data, n): 
    """Takes a list and an integer and returns the nth item of the        
    list"""
    print(data[n])

item = nth_item([10, 20, 30], 0) 
print(item)
    """should result with:
    10
    but keep getting:
    10
    None
    """
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Hugo Smith
  • 15
  • 4

0 Answers0