Sep-24-2017, 12:23 AM
First, note that I added empty brackets to 'new_list' on line 2.
Second, this only works if the list consists of strings.
Finally, I am probably making every Python coder groan by my my use of
So the first loop takes the original list and breaks it into individual characters. The second loop prints the list 1 character at a time.
If we add a print() statement after the first loop:
Second, this only works if the list consists of strings.
Finally, I am probably making every Python coder groan by my my use of
for item in range(len(a_list))
and for character in range(len(new_list))
. Be that as it may...So the first loop takes the original list and breaks it into individual characters. The second loop prints the list 1 character at a time.
If we add a print() statement after the first loop:
for item in range(len(a_list)): new_list.extend(a_list[item]) print(new_list)we get
Output:['1', '1', 'm', 'a', 'r', 'y', '1', '1', '0']
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition