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 - i want to add a value in the dictionary
- python - i want to add 5 to each value in the list
- python - i want to add text to an image with pil
- python 3x - i want to read a string from a file in python
- Python sorted sort list and dict
- python - i want to read jpeg photos and rewrite exif
- python - i don't know how to add +1 to user-specific functions and functions
- python - i want to extract df conditionally
- python 3x - i want to output characters to a text box
- python 3x - i want to erase the parentheses
- python - i want to solve noreversematch
- python - i want to save multiple images
- python - the image i want to output is not output
- python - i want to search data from json format dat file
- python 3x - when using ">" in the list comprehension
- python - i want to convert a text file into a voice file
- html - i want the characters in the list to be two lines
- python - i want to convert h5 file to mlmodel
- python - ask about simultaneous progress
- i want to output a 3d graph with parse effect using python
- how to manually execute a python file created in a python program
- how to write the code of face calculation (send + more==money) in python
- python - i want to detect the position of a traffic light and display a movie with opencv
- python - i want to add image processing to a video with opencv and play it back in a loop
- i want to output to python data frame format while maintaining the correspondence between cells of html table
- python - importerror: no module named'imblearn'
- python - the error "nvrtc_error_compilation (6)" when implementing cupy cannot be avoided
- create and operate excel from scratch with python