Skip to content

Instantly share code, notes, and snippets.

@smhatre59
Created June 5, 2019 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smhatre59/a65c23aa8fb2d883afcaf03d54257204 to your computer and use it in GitHub Desktop.
Save smhatre59/a65c23aa8fb2d883afcaf03d54257204 to your computer and use it in GitHub Desktop.
sampleTuple = (12, 10, 14, 18, 20, 22, 12)
#print a tuple
print(sampleTuple)
#Output: (12, 10, 14, 18, 20, 22, 12)
#print number of times 12 appears in the tuple
print(sampleTuple.count(12))
#Output: 2
#Search for the first occurrence of the value 14, and return its position:
print(sampleTuple.index(18))
#Output: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment