list = [8,4,3,2,5]
Is there a way to join two elements not using slice
print ' '.join(list[0:3]) #would print out the numbers in between
What if I want to print just those specific elements?
You can use Python's string formatter :
>>> arr = [8,4,3,2,5]
>>> print "{0} {3}".format(*arr)
8 2
Also, please don't name your variables after built-in functions/types such as list
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.