This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original_phrase = 'foo bar' | |
reversed_list = [word for word in reversed(original_phrase.split())] | |
reversed_phrase = ' '.join(reversed_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
client = MongoClient() | |
db = client.your_mongo_db | |
responses = db.your_mongodb_collection.find( { 'field_name': {'$regex' : "regular_expresion", "$options" : "i"} } ) | |
for response in responses: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b, a = a, b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ".join(a_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
count = Counter(a_list_of_repeated_elements) | |
print(count.most_common(3)) # Show the 3 more frequent elements of a list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original_phrase = 'foo bar' | |
reversed_phrase = '' | |
for character in reversed(original_phrase): | |
reversed_phrase += character |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original_list = ['foo', 'bar'] | |
reversed_list = list() | |
for l in reversed(original_list): | |
reversed_list.append(l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original_array = [['a',1], ['b',2], ['c',3]] | |
transposed_array = zip(*original_array) | |
list(transposed_array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new_list = old_list.copy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from copy import deepcopy | |
old_list = [[1,2], [3,4]] | |
new_list = deepcopy(old_list) |
OlderNewer