Skip to content

Instantly share code, notes, and snippets.

@anandrajneesh
Created May 10, 2019 06:41
Show Gist options
  • Save anandrajneesh/d1998017ca78ed9cd28ba23debe320b9 to your computer and use it in GitHub Desktop.
Save anandrajneesh/d1998017ca78ed9cd28ba23debe320b9 to your computer and use it in GitHub Desktop.
Python
items = [12, 2, 'str', [], {}]
print(items)
for i in range(0, len(items)):
print(items[i])
print(items[1:3])
print(items * 3)
print(items + items)
print(12 in items)
items.append(4)
print(items)
items.extend(items)
print(items)
print(items.index(12))
print(items.count(12))
items.reverse()
print(items)
items.reverse()
nums = [1, 2, 3, 4, 5, 6, 11, 10]
nums.sort()
print(nums)
x = nums.copy()
print(x)
x.clear()
print(x)
for z in items:
print(z)
items.pop(0)
L = [x**2 for x in range(5)]
print(L)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment