-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sequences_ikram_celal_keskin.py
- Loading branch information
1 parent
e18f513
commit 8f938a6
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
|
||
def remove_duplicates(seq:list) -> list: | ||
''' | ||
This function removes duplicates from a list | ||
Args: | ||
seq (list): Input list with potential duplicates | ||
Returns: | ||
list (list): List with duplicates removed | ||
''' | ||
return list(set(seq)) | ||
|
||
def list_counts(seq:list) -> dict: | ||
''' | ||
This function counts the occurences of each element in a list | ||
Args: | ||
seq (list): Input list to count occurences of each element | ||
Returns: | ||
dict (dict): Dictionary with elements as keys and occurences as values | ||
''' | ||
count={} | ||
|
||
for i in seq: | ||
count[i]=seq.count(i) | ||
|
||
return count | ||
#{i: seq.count(i) for i in seq} | ||
|
||
def reverse_dict(d:dict) -> dict: | ||
''' | ||
This function reverses the keys and values of a dictionary | ||
Args: | ||
d (dict): Input dictionary to reverse keys and values | ||
Returns: | ||
dict (dict): Dictionary with keys and values reversed | ||
''' | ||
|
||
reversed={} | ||
|
||
for key, value in d.items(): | ||
reversed[value] = key | ||
|
||
return reversed | ||
#return {v: k for k, v in d.items()} |