Skip to content

Instantly share code, notes, and snippets.

@onitonitonito
Last active June 29, 2017 01:02
Show Gist options
  • Save onitonitonito/77f0080bf80a515f8286d9c48eb6ca7d to your computer and use it in GitHub Desktop.
Save onitonitonito/77f0080bf80a515f8286d9c48eb6ca7d to your computer and use it in GitHub Desktop.
Guess why? - looks a bit weird result.. describe WHY?
# Two Different Results
# Compare #A-1 to #B-1
# Guess why? thinking about join() function.
# board = [[ str(n) for n in range(7,12) ]] #A
board = [ str(n) for n in range(7,12) ] #B
print (board)
for t in board:
print('|'+'|'.join(t)+'|') #1
# print('|'.join(t)+'|') #2
# print(','.join(t)) #3
# '''
# #A-1
# [['7', '8', '9', '10', '11']]
# |7|8|9|10|11|
# [Finished in 2.36s]
#
# #B-1
# ['7', '8', '9', '10', '11']
# |7|
# |8|
# |9|
# |1|0|
# |1|1|
# [Finished in 1.83s]
#
# Why #A-1 spent more time?
# '''
@onitonitonito
Copy link
Author

onitonitonito commented Jun 29, 2017

a = "Life is Short, You Need Python"
b = "ABRAKADABRA"
c = ['1','2','3','4','5']
d = [1,2,3,4,5]

print(','.join(a))
print(','.join(b))
print(','.join(c))
print(str(d))
print(','.join(str(d)))
print('#'.join(str(d)))

L,i,f,e, ,i,s, ,S,h,o,r,t,,, ,Y,o,u, ,N,e,e,d, ,P,y,t,h,o,n
A,B,R,A,K,A,D,A,B,R,A
1,2,3,4,5
[1, 2, 3, 4, 5]
[,1,,, ,2,,, ,3,,, ,4,,, ,5,]
[#1#,# #2#,# #3#,# #4#,# #5#]
[Finished in 2.153s]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment