Is there a way I can transfer appended values into a nested list within one list? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there a way I can transfer appended values into a nested list within one list?

list1 = [] highEndSD = input("Enter the high-end spotlight driver: ") list1.append(highEndSD) highEndSK = input("Enter the high-end spotlight kart: ") list1.append(highEndSK) highEndSG = input("Enter the high-end spotlight glider: ") list1.append(highEndSG) for highEndD in range(4): highEndD = input("Enter a high-end driver: ") list1.append(highEndD) #Transfer all appended values (highEndD) into a nested list without deviating from the original (list1).

24th Nov 2019, 9:07 PM
Steven Iannucci
Steven Iannucci - avatar
1 Answer
+ 1
So you want to store SK, SD AND SG each separately, but you want all four Ds in a list, that you put into your original list? That would look like this: ... highEndDs = [] for highEndD in range(4): highEndD = input("Enter a high-end driver: ") highEndDs.append(highEndD) list1.append(highEndDs) (I hope that's what you had in mind.)
25th Nov 2019, 12:09 AM
HonFu
HonFu - avatar