Hi, there
I have been confused about format control of List. My problem is that I get strange format when exchanging List[-1] with List[-2] using a middle variable. My code is to handle a text file.
Old code in a For loop is:
sinf.write('*element,type=s4r,elset=WSLAB\n')
path4b2_value[0]=str(int(path4b2_value[0])+100000)
path4b3=','.join(path4b2_value)
sinf.write(path4b3)
which produces a proper format
*element,type=s4r,elset=WSLAB
100001,6,4719,12,6308
*element,type=s4r,elset=WSLAB
100002,4719,2328,6308,2327
However I need to exchange the location of the final two elements in the List, so I changes my code as
The corresponding new code in the For loop is:
sinf.write('*element,type=s4r,elset=WSLAB\n')
path4b2_value[0]=str(int(path4b2_value[0])+100000)
path4b2_temp=path4b2_value[-1]
path4b2_value[-1]=path4b2_value[-2]
path4b2_value[-2]=path4b2_temp
path4b3=','.join(path4b2_value)
path4b3=path4b3+'\n'
sinf.write(path4b3)
which prodcues
*element,type=s4r,elset=WSLAB
100001,6,4719,6308
,12
*element,type=s4r,elset=WSLAB
100002,4719,2328,2327
,6308
Yes I did exchange the location of the final two element of the list. However I got strange format.
I cannot understand threason why this phenomenon happens. Could you please help me out?
best wishes
ning