- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I create a non-literal python tuple?
You can first construct a list then change the single value you want to change, then finally convert that to a tuple if you want to create a non-literal python tuple. For example,
def create_non_literal_tuple(a, b, c): x =  * a x[c] = b return tuple(x) create_non_literal_tuple(6, 0, 2)
This will give the output:
(1, 1, 0, 1, 1, 1)
A 0 in position 2 of an array of length 6.
- How can I create a Python tuple of Unicode strings?
- How can I append a tuple into another tuple in Python?
- How can I do Python Tuple Slicing?
- How I can convert a Python Tuple into Dictionary?
- How can I convert a Python tuple to string?
- How can I subtract tuple of tuples from a tuple in Python?
- How can I use Multiple-tuple in Python?
- How can I convert Python strings into tuple?
- How can I remove items out of a Python tuple?
- How can I define duplicate items in a Python tuple?
- How can I convert a Python tuple to an Array?
- How I can dump a Python tuple in JSON format?
- How can I convert a Python Named tuple to a dictionary?
- How can I convert Python tuple to C array?
- How can I represent python tuple in JSON format?