0

List 1[], List2[]?

list 1 = [] list2 = [] for i in range(5)[::-1]: list1.append(i) for j in list1[::-2]: list2.append(j+1) print(list1[2]) Solution: 2 So confused. It says append, but does not say with what?

2nd Apr 2019, 6:15 AM
tristach605
tristach605 - avatar
4 Answers
0
I see. Thanks TT. BTW, what would "print(list2[2]) be? "j in list1[::2]: list2.append(j+1)" -2 in range 5[::-1] would be 2 also, right?
2nd Apr 2019, 7:21 AM
tristach605
tristach605 - avatar
0
Thanks TT! I took your advice and played around with the code constructing abd deconstructing it. I left a special note for you at the end, and got the same code to print, in a loop, from 4 to 0 and from 0 to 4:). Another mistake I made was not recognizing that "append(i) was a command? like i still need someone to yell "go" or "commute" to queue me. LOL. Anyway, thanks for the helpđŸ‘đŸ» list_a = [] list_b = [] for all_nums in range(5)[::-1]: list_a.append(all_nums) for anums in range(10)[::1]: list_b.append(anums) print(list_a[0]) print(list_a[1]) print(list_a[2]) print(list_a[3]) print(list_a[4]) print(list_b[0]) print(list_b[1]) print(list_b[2]) print(list_b[3]) print(list_b[4]) print("Thanks TT!")
2nd Apr 2019, 11:04 PM
tristach605
tristach605 - avatar