Python Forum

Full Version: How do i make a new lists out of an list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to make my first app and was wondering how do I make a list out of a list. Following some tutorials on udemy .

list_body = ["head","arms","legs"]
list_head = ["eyes","nose","mouth"]
list_eyes = ["color","shape"]
The concept is as this:
Body is my main list followed up by a -> new list Head, which has its lists -> Eyes

I understand it so far: I run a for loop through all body parts then I attach all head data to head but I'm not sure how to do this.
print(muscle_group)
empty_muscle_group = []
for number_list in muscle_group:
    empty_muscle_group.append(number_list)
print(empty_muscle_group)
this is what iv come across so far. I will allow inputs to be done to add new data but for now, I want to understand the basics
Here are various ways to copy a list
>>> body =  ["head","arms","legs"]
>>> another = list(body)
>>> another
['head', 'arms', 'legs']
>>> body.append('feet')
>>> body
['head', 'arms', 'legs', 'feet']
>>> another
['head', 'arms', 'legs']
>>> one_more = [x for x in body]
>>> one_more
['head', 'arms', 'legs', 'feet']
>>> again = body[:]
>>> again
['head', 'arms', 'legs', 'feet']
>>> import copy
>>> yet_another = copy.copy(body)