Skip to content

Commit

Permalink
Create sequences_ikram_celal_keskin.py
Browse files Browse the repository at this point in the history
  • Loading branch information
icelal-kskn committed Oct 14, 2024
1 parent e18f513 commit 8f938a6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Week03/sequences_ikram_celal_keskin.py
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()}

0 comments on commit 8f938a6

Please sign in to comment.