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?
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]
+ 1
a = int(input())
b = int(input())
ls = list(range(a,b))
print(ls)
https://code.sololearn.com/cwREeQEyanz5
+ 1
Thank you
0
print (i,end=',')
0
Also square brackets at the end