id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Athenian: List Practicelist_indexing2

prev  |  next  |  chance

Predict the returned value
by Tracy '23

def return_elements_in_lists(x):
    list1 = ['red','yellow','orange','grey','green','purple','blue']
    list2 = ['computer','calculator','cellphone','keys','ipad','stylus']
    if x % 2 == 0:
        return list1[x]
    else:
        return list2[x-1]
Function Call  Return Value
return_elements_in_lists(2)
return_elements_in_lists(3)
return_elements_in_lists(5)
return_elements_in_lists(1)
return_elements_in_lists(6)

Experiment with this code on Gitpod.io

⬅ Back