answersLogoWhite

0

>>> list1 = [3,5]

>>> list2 = ['foo','bar']

>>> ans = list1

>>> print ans

[3, 5]

>>> for var in list2:

ans.append(var)

>>> print ans

[3, 5, 'foo', 'bar']

this might not be the most efficient way to add lists together but it works.

ans.append(var) means to add the variable 'var' to the end of list 'ans'. the reason I put this in a for loop is if I just said ans.append(list2), the answer would be [3,5,['foo,bar']].

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

List the five largest pythons in the world with their lengths?

reticulated python - 33 ft (record) burmese python - 18 ft African rock python - 19ft amethystine python - 25 (record) carpet python - 10ft


When was the Indian python put on the endangered list?

the year 1


Where can one obtain a Python list?

Python lists can't be downloaded from an adress or website source. They have to be created in the Python programming language. Lists can then be created by using a text editor.


What is the time complexity of finding the maximum element in a list using the Python max function?

The time complexity of finding the maximum element in a list using the Python max function is O(n), where n is the number of elements in the list.


How do you add contact to g mail chat list?

You can add contact to Gmail chat list. You have to add the contact to the list. After adding you have to add the request to the person


Can you provide an example of how c/em is used in a programming language?

In programming languages, c/em (short for comments) are used to add explanations or notes within the code that are ignored by the compiler or interpreter. For example, in Python, you can use the symbol to add comments like this: python This is a comment in Python print("Hello, World!")


List some alternate web scripting languages to PHP?

Ruby, Python, Perl


What are tuples in the python programing language?

A tuple is a collection in Python that is ordered and cannot be changed (immutable) after creation. # Creating a tuple my_tuple = ("apple", "banana", "cherry") # Accessing elements print(my_tuple[0]) # Output: apple For more Python tutorials, visit jiten.fun 🚀


How can I efficiently use the np permute function in Python to generate all possible permutations of a given list?

To efficiently use the np permute function in Python to generate all possible permutations of a given list, you can first import the numpy library and then use the np permute function with the list as an argument. This will return an array of all possible permutations of the elements in the list.


How can I install a Python package using the command "python setup.py install" for a specific user?

To install a Python package for a specific user using the command "python setup.py install", you can use the "--user" flag. This flag will install the package only for the current user, rather than system-wide. Simply add "--user" to the end of the command like this: "python setup.py install --user".


What are the top 5 longest snakes?

1. Reticulated python 2. Scrub python 3. Green anaconda 4. African rock python 5. Burmese python 6. King cobra 7. Boa constrictor 8. Black-tailed python 9. Keeled rat snake 10. Tiger rat snake I'm sure there's lots of room for dispute on the bottom half of that list.


What is the common name of the ball python?

The ball python (Python regius), also called the royal python, is a python species native to West and Central Africa, where it lives in grasslands, shrublands and open forests. It is listed as Least Concern on the IUCN Red List because of its wide distribution. It is threatened by hunting for its meat and for the international pet trade, where it is the most popular pet snake in the world. This nonvenomous constrictor is the smallest of the African pythons, growing to a maximum length of 182 cm (72 in).The name "ball python" refers to its tendency to curl into a ball when stressed or frightened. Learn For more OnlineITGuru