Advertisement
DimaT1

tuple in python

Mar 16th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. >>> a = (1, 2, 3, 4, 5, 6)
  2. >>> a[3]
  3. 4
  4. >>> a[2:]
  5. (3, 4, 5, 6)
  6. >>> a[:3]
  7. (1, 2, 3)
  8. >>> a[2:3]
  9. (3,)
  10. >>> a[2:6]
  11. (3, 4, 5, 6)
  12. >>> a[2:6:2]
  13. (3, 5)
  14. >>> a[::-1]
  15. (6, 5, 4, 3, 2, 1)
  16. >>> d = {(1, 1, 1) : 1}
  17. >>> d
  18. {(1, 1, 1): 1}
  19. >>> a = (5,)
  20. >>> a
  21. (5,)
  22. >>> a = tuple('hello, world!')
  23. >>> a
  24. ('h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement