How to combine a group of lists together
DL Neil
PythonList at DancesWithMice.info
Sat Dec 21 00:48:43 EST 2019
On 21/12/19 6:04 pm, wanghao7915 at gmail.com wrote:
> I utilized .get_text() + .split() functions and obtain this:
> spe=
> ['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details']
> ['4.7', 'inches']
> ['750', 'x', '1334']
> ['64', 'GB']
> ['2', 'GB']
> ['Apple', 'A11', 'Bionic,', 'Hexa-Core,', '(2x', 'Monsoon', '+', '4x', 'Mistral)']
> ['5.22', 'ounces']
> ['No']
> ['No']
> ['12', 'MP']
> ['7', 'MP']
> ['1821', 'mah']
> ['No']
> ['Yes,', 'on', 'the', 'front']
> ['None']
> ['iOS', '(Last', 'OS', 'info:', 'IOS', '11)']
> ['September', '2017']
>
> They have a shared name 'spe', but no concrete names for each list.
> If I use spe[0], I can only get all the first element of each list.
>
> How can I mix all of these elements into a single list like:
> ['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details','4.7', 'inches'......]
What is type( spe )? Please copy-paste code/session into your email msg
- the above is NOT Python.
Your best solution may be to use a loop (instead of the constant 0, as
list-argument).
The answer to your specific question is 'in the manual': list.extend()
(but a loop will likely still be required...)
WebRef:
https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range
--
Regards =dn
More information about the Python-list
mailing list