I want to add another list to the list, but if I do something like below, [['A','B','C']] It will not be possible to take out.
I want to say ['A','B','C'] What should I do?
list =  output =  list.append ("A") list.append ("B") list.append ('C') output.append (list) print (output)
In addition, I think that it was written in the book that variable declaration is not necessary in python,
I created a variable called list, and I thought that "A" was in it, but I got an error.
list = 
I am doing this because it is fixed when I do something like a declaration first, but is this correct?
Excuse me. ['A','B','C'] could be retrieved with output .
I want to tell you whether output  can extract'A&apos ;.
Answer # 1
Are you going to add lists?
In such cases, use list # extend instead of list # append.
>>>lst = list ('ABC') >>>lst ['A', 'B', 'C'] >>> >>>output =  >>> >>>output.extend (lst) >>>output ['A', 'B', 'C'] >>> >>>output + = lst # This is fine >>>output ['A', 'B', 'C', 'A', 'B', 'C']
I think it was written in the book that python doesn't need variable declarations
Variable names and objects are only dynamically associated with assignments.
Please do not name variables as
Causes errors that are difficult to resolve.
>>>list ('ABC') ['A', 'B', 'C'] >>> >>>list = [1, 2, 3] >>> >>>list ('ABC') Traceback (most recent call last): File "<stdin>", line 1, in<module> TypeError: 'list' object is not callable
Answer # 2
The intended action is probably
Variable declaration and initialization are separate. More specifically, types don't have to be written in python.
Because it is a dynamically typed language, there is no need to indicate that a
listtype variable called
listis used. I think you are saying.
As a matter of fact, if you write a process that creates an empty list and adds elements, you need to create an empty list and bind it to a variable.
Using the variable name
listwill override the built-in
listclass. Avoid using variable names that cover other things.
- python - in the list data, i want to get the same hourly total for each day
- python - how to add a list to a list with a zip function
- i want to make a list containing a list flat in python
- python - if you want to get a list of the list of pages with css selector
- i want to plot a list in a python dataframe
- python - i want to list elements by date from a list with dates and elements
- python 3x - i want to read another python file with python
- about import from another directory in python
- python 3x - i want to read a string from a file in python
- i want to run in a python line extraction loop
- python 3x - conversion from list type to int type
- python - i want to mention a role in discordpy
- i am a python beginner i want you to help me
- i want to detect a ball with python+opencv
- python 3x - i want to run another python script from a python script
- i want to add curl to php7
- python - i want to write the value at each x of f(x) to txt
- python - i want to stop a def function from another def function
- python - i want to delete """ and "\" added to json data
- i want to get the day of the week in python
- python - about "could not retrieve index file" error
- call function dynamically in python
- http error 503: service unavailable when doing amazon scraping with python
- python - cannot output the created sound data
- python even number sorts odd numbers
- python - [natural language processing] regarding back propagation of embedding layer when word2vec is implemented
- python - modelpredict() cannot be executed in tensorflow
- python csv even odd sorting method
- python - i want to change optional arguments according to conditions
- i want to replace every other character using python regular expression