Answers for "python print array"

5

python print array

#Setting The Array:#

array = [250,630,221] #You can have as many items as you want#

#Printing The Whole Array:#

print(array)
#output = [250, 630, 221,]#

#Printing Individual Items From The Array:#

print(array[0])
#output = 250#

print(array[1])
#output = 630#

print(array[2])
#output = 221#
#array[0] is the 1st array item, array[1] the 2nd, and so on#

#Printing Multiple Items From The Array:#

print(array[2],array[0])
#output = 221#
Posted by: Guest on August-09-2020
1

printing a list in python

items = [1,2,3,4,5,6]

#print with [] brackets separated by ','
print(items)

#print using operator
print(*items)

#print using for 
for i in items:
    print(i)
    
#print using for and len function
for i in range(len(items)):
    print(items[i])

#you can also add sep and end methods to the print statement accordingly
Posted by: Guest on June-04-2020
1

print value of array python

visit = ['noah-', 'chatelain', '.fr']

print visit[0] # return string : 'noah-'
print visit[1] # return string : 'chatelain'
print visit[2] # return string : '.fr'

print 'go visit : ' + visit[0] + visit[1] + visit[2]
# return 'go visit : noah-chatelain.fr'
Posted by: Guest on March-19-2020
0

python print an array

a = [1,2,3,4,5]
print(a)
Posted by: Guest on January-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language