How to create a tuple with repeated value in Python

1 Answer

0 votes
tpl = tuple((0,1) for _ in range(5))

print(tpl)



'''
run:

((0, 1), (0, 1), (0, 1), (0, 1), (0, 1))

'''

 



answered Nov 26, 2022 by avibootz

Related questions

1 answer 238 views
238 views asked Oct 29, 2018 by avibootz
1 answer 200 views
1 answer 187 views
1 answer 230 views
...