Skip to content

Instantly share code, notes, and snippets.

@bbrother92
Last active May 4, 2019 01:38
Show Gist options
  • Save bbrother92/8d87aff1f147220bf73a95fa21c69583 to your computer and use it in GitHub Desktop.
Save bbrother92/8d87aff1f147220bf73a95fa21c69583 to your computer and use it in GitHub Desktop.
#python
def foo(bar=[]): # bar is optional and defaults to [] if not specified
... bar.append("baz") # but this line could be problematic, as we'll see...
... return bar
#=========
print dir(math)
print type(2.)
duck_index =animals.index("duck") # Use index() to find "duck"
animals = animals.insert(duck_index,"cobra")
square_list.sort()
// =======
from datetime import datetime
now = datetime.now()
print '%s/%s/%s' % (now.month, now.day, now.year)
print '%s:%s:%s' % (now.hour, now.minute, now.second)
// =======
for i in range(0,10):
print random.randint(0,2)
// =======
for a,b in zip(a,b):
print a+b
// =======
for index,a in enumerate(a):
print index,a
// =======
def reverse(text):
temp = ""
for i in range(len(text)-1,-1,-1):
temp =temp + text[i]
return temp
// =======
def anti_vowel(text):
text= list(text)
for c in range(0,len(text)):
if text[c] in "aeiouAEIOU":
text[c] = ""
return ''.join(text)
print anti_vowel("abce")
// =======
sorted([6, 8, 12, 2, 23])
my_string.count("d")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment