Ok so I would be asking in my class forum but the systems down and this is killing me (No its not the answer to a question). I was doing an assignment when I came across a weird behavior in python 3 for some reason it brutally ripped apart one of my string that I had in a list. It yanked that thing into individual characters including the ' ' white spaces. All the sudden I was like neo in the matrix "whow" I use Spyder (IDE) so I can go through it step by step. HOWEVER when I run this line >>> x[len(x):-1] = p[q] python turns into an axe murderer and goes all crazy on it I can see that python sees the string as a str like it should but for some reason instead of getting output that looks like this
['see spot run', 'y', 3, 4, 5, 6, 1, 'q', 't', 2, 100]
i am getting
['s', 'e', 'e', ' ', 's', 'p', 'o', 't', ' ', 'r', 'u', 'n', 'y', 3, 4, 5, 6, 1, 'q', 2, 100]
WHY????? ITS DRIVING ME CRAZY I MUST KNOW!!!!
p.s. here is my code:
x=[]
w=['t',2,'y',3,100]
y=['see spot run','y',3]
z=[4,5,6,1,'q']
p=x+y+z+w
q=0 n=[0]
for item in p:
if p[q] in x:
q=q+1
continue
else:
try:
x[len(x):-1] = p[q] ##<--- This is the line thats going crazy
except TypeError:
n[0] = p[q]
x=x+n
q=q+1
print(x)