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 145 views
145 views asked Oct 29, 2018 by avibootz
1 answer 115 views
2 answers 110 views
2 answers 192 views
1 answer 149 views
...