This file contains hidden or 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 UserList | |
from urllib.parse import urlparse | |
import json | |
import requests | |
def recursive_key_values(dictionary): | |
for key, value in dictionary.items(): | |
i = 0 | |
if type(value) is str: |
This file contains hidden or 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
import functools | |
a = [5, 7, 9, 11] | |
b = [1, 20, 30, 40] | |
c = [3, 3, 3, 6] | |
answers = list(map(lambda x, y, z: (x + y) / z, a, b, c)) | |
assert answers == [2.0, 9.0, 13.0, 8.5] | |
summation = functools.reduce(lambda x, next_reduce: x + next_reduce, [2.0, 9.0, 13.0, 8.5]) |
This file contains hidden or 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
import typing | |
def get_indices(the_list: list, test_value: object) -> typing.Iterable[int]: | |
""" | |
Returns the indices of matching list items. | |
Uses a generator to create an iterator. | |
Args: | |
the_list: the list containing search elements | |
test_value: what we want to find |
This file contains hidden or 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 UserList | |
class UniquesList(UserList): | |
""" | |
A List Class which works just like a list, except | |
that it only holds unique values - similar to a set. | |
>>> ul = UniquesList("The Jolly Green Giant") | |
>>> print("".join(ul)) |
This file contains hidden or 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
hello: str = 'Hello World!' | |
assert len(hello) == 12 | |
This file contains hidden or 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
hello: str = 'Hello World!' | |
assert len(hello) == 12 | |
This file contains hidden or 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
hello: str = 'Hello World!' | |
assert hello[6] == 'W' |
This file contains hidden or 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
hello: str = 'Hello World!' | |
assert hello[-6] == 'W' |
This file contains hidden or 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
hello: str = 'Hello World!' | |
print (list(enumerate(hello))) |
This file contains hidden or 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
hello: str = 'Hello World!' | |
print(hello[3:8]) | |
assert hello[3:8] == 'lo Wo' |