Reputation: 37
I am trying to make convert a list into a string so i can print it and show my desired outcome however, for some reason, the join function is not working like it was before.
This is my code:
xno = 5
yno = 10
exis =xno*'x'
list1 = ('.',exis,'-')*yno
str1 = ''.join(list1)
strop = str(str1)
flist = strop.split('-')
'\n'.join(flist)
print(flist)
Upvotes: 0
Views: 219
Reputation: 541
In Python, join
will return a new value but won't modify the list reference passed in.
You could set a variable as such:
list_str = '\n'.join(flist)
print(list_str)
or, just pass the join
function into print
:
print('\n'.join(flist))
Upvotes: 2