0

How do I add a coma in this

a = int(input()) b = int(input()) for i in list(range(a,b)): print (i) How do I add a comma in-between the numbers and a square bracket at both ends?

23rd Dec 2021, 4:32 PM
Ash Sharif
Ash Sharif - avatar
5 Respostas
+ 6
Ash Sharif , here is a more detailed version that may give a better understanding also with comments of how it is working: a = int(input()) b = int(input()) lst = [] # create a new empty list # use range() function to generate the numbers from.. upto ... we need to add +1 since the upper bound value is not included in the range for i in list(range(a, b + 1)): lst.append(i) # add each nunber that is generated from range to the list print (lst) # output list for input 1 and 4 the result is: [1, 2, 3, 4]
23rd Dec 2021, 6:26 PM
Lothar
Lothar - avatar
+ 1
a = int(input()) b = int(input()) ls = list(range(a,b)) print(ls) https://code.sololearn.com/cwREeQEyanz5
23rd Dec 2021, 5:59 PM
SoloProg
SoloProg - avatar
+ 1
Thank you
23rd Dec 2021, 10:46 PM
Ash Sharif
Ash Sharif - avatar
0
print (i,end=',')
23rd Dec 2021, 4:35 PM
Avinesh
Avinesh - avatar
0
Also square brackets at the end
23rd Dec 2021, 4:37 PM
Ash Sharif
Ash Sharif - avatar