Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/functions.cpython-313.pyc
Binary file not shown.
28 changes: 28 additions & 0 deletions functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# functions.py

import string

# 1. Returns a new list with unique elements (keeps first appearance)
def get_unique_list_f(lst):
unique = []
for item in lst:
if item not in unique:
unique.append(item)
return unique


# 2. Counts uppercase and lowercase letters in a string
def count_case_f(string):
upper_count = sum(1 for char in string if char.isupper())
lower_count = sum(1 for char in string if char.islower())
return upper_count, lower_count

# 3. Removes punctuation marks from a sentence
def remove_punctuation_f(sentence):
return ''.join(char for char in sentence if char not in string.punctuation)

# 4. Counts the number of words in a given sentence after removing punctuation
def word_count_f(sentence):
clean_sentence = remove_punctuation_f(sentence)
words = clean_sentence.split()
return len(words)
Loading