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 241 views
241 views asked Oct 29, 2018 by avibootz
1 answer 200 views
1 answer 188 views
1 answer 232 views
...