import re

"""
First Task
"""

# Initial Persons
persons_list = []

for index in range(1, 4):

    print(f"Person number {index}:")

    person = {
        'name': input('Enter your name\n'),
        'age': int(input('Enter your age\n'))
    }
    persons_list.append(person)


# 1)
for person in persons_list:
    if person['age'] < 27:
        person['name'] = 'Jimmy Hendrix'

print(persons_list)

# 2)
for person in persons_list:
    if 't' in person['name'].lower():
        person['age'] += 1
        print(f"""Happy bday {person['name']}
Your are {person['age']} years old.""")

# 3)
counter = 0

while counter < persons_list[0]['age']:
    if not counter % 2 == 0:
        print(counter)
    counter += 1

# 4)
e_letter = 'e'

for person in persons_list:
    if e_letter in person['name'].lower():

        lower_person = person['name'].lower()

        if lower_person.startswith(e_letter):
            print(f"{e_letter} in index 0")
        elif lower_person[1] == e_letter:
            print(f"{e_letter} in index 1")
        else:
            print(f"{e_letter} in index {person['name'].find(e_letter)}")

"""
Second Task
"""

# Initial Time
time = int(input('Enter time in minutes'))

# 1)
hours = int(time / 60)
minutes = time - (hours * 60)

print(f"hours: {hours}, minutes: {minutes}")

# 2)
if hours >= 1:
    if hours < 2:
        print("Ok...")
    else:
        print("Trilogy")

# 3)
if minutes > hours:
    if minutes % 2 == 0:
        hours *= 2
    else:
        minutes -= 1
else:
    print(hours)

print(f"Hours: {hours}, Minutes: {minutes}")

"""
Third Task
"""

# Creating the file

file_content = """
My my candle candle burns at both ends;
It will not last the night;
But ah, my foes, and oh, my friends—
It gives a lovely light!
"""

file_path = "file.txt"

with open(file_path, mode='w') as my_file:
    my_file.write(file_content)

# Reading the file

with open(file_path, mode='r') as my_file:
    reading_content = my_file.read()


# 1)
all_words = reading_content.split()

# 2)
all_words_set = set({})

#
for word in all_words:
    word = re.sub(r"[^A-Za-z]+", "", word)
    all_words_set.add(word.lower())

# 3)
for word in all_words_set:
    if word.startswith('t'):
        print(f"Word ({word}) starts with 't'")

# 4)
for word in all_words_set:
    if word.lower().startswith('a'):
        print(f"Word: {word}")
        print("Letters:")
        for letter in word:
            print(letter)

# 5) Short way
words_tuple = tuple(word for word in all_words if 'a' not in word.lower())
print(words_tuple)

# 5) Long way
to_be_tuple = []
for word in all_words:
    if 'a' not in word.lower():
        to_be_tuple.append(word)

to_be_tuple = tuple(to_be_tuple)
print(to_be_tuple)

# 6) Short way
new_e_words = [e_word.replace('e', '3') for e_word in all_words_set if 'e' in e_word]
print(new_e_words)

# 6) Long way
e_to_3 = []

for word in all_words_set:
    if 'e' in word:
        new_word = word.replace('e', '3')
        e_to_3.append(new_word)

print(e_to_3)


ab3678938de30d32401f44444ae5381121e5dcac
<mask token>

<mask token>
for index in range(1, 4):
    print(f'Person number {index}:')
    person = {'name': input('Enter your name\n'), 'age': int(input(
        'Enter your age\n'))}
    persons_list.append(person)
for person in persons_list:
    if person['age'] < 27:
        person['name'] = 'Jimmy Hendrix'
print(persons_list)
for person in persons_list:
    if 't' in person['name'].lower():
        person['age'] += 1
        print(
            f"Happy bday {person['name']}\nYour are {person['age']} years old."
            )
<mask token>
while counter < persons_list[0]['age']:
    if not counter % 2 == 0:
        print(counter)
    counter += 1
<mask token>
for person in persons_list:
    if e_letter in person['name'].lower():
        lower_person = person['name'].lower()
        if lower_person.startswith(e_letter):
            print(f'{e_letter} in index 0')
        elif lower_person[1] == e_letter:
            print(f'{e_letter} in index 1')
        else:
            print(f"{e_letter} in index {person['name'].find(e_letter)}")
<mask token>
print(f'hours: {hours}, minutes: {minutes}')
if hours >= 1:
    if hours < 2:
        print('Ok...')
    else:
        print('Trilogy')
if minutes > hours:
    if minutes % 2 == 0:
        hours *= 2
    else:
        minutes -= 1
else:
    print(hours)
print(f'Hours: {hours}, Minutes: {minutes}')
<mask token>
with open(file_path, mode='w') as my_file:
    my_file.write(file_content)
with open(file_path, mode='r') as my_file:
    reading_content = my_file.read()
<mask token>
for word in all_words:
    word = re.sub('[^A-Za-z]+', '', word)
    all_words_set.add(word.lower())
for word in all_words_set:
    if word.startswith('t'):
        print(f"Word ({word}) starts with 't'")
for word in all_words_set:
    if word.lower().startswith('a'):
        print(f'Word: {word}')
        print('Letters:')
        for letter in word:
            print(letter)
<mask token>
print(words_tuple)
<mask token>
for word in all_words:
    if 'a' not in word.lower():
        to_be_tuple.append(word)
<mask token>
print(to_be_tuple)
<mask token>
print(new_e_words)
<mask token>
for word in all_words_set:
    if 'e' in word:
        new_word = word.replace('e', '3')
        e_to_3.append(new_word)
print(e_to_3)

<mask token>
persons_list = []
for index in range(1, 4):
    print(f'Person number {index}:')
    person = {'name': input('Enter your name\n'), 'age': int(input(
        'Enter your age\n'))}
    persons_list.append(person)
for person in persons_list:
    if person['age'] < 27:
        person['name'] = 'Jimmy Hendrix'
print(persons_list)
for person in persons_list:
    if 't' in person['name'].lower():
        person['age'] += 1
        print(
            f"Happy bday {person['name']}\nYour are {person['age']} years old."
            )
counter = 0
while counter < persons_list[0]['age']:
    if not counter % 2 == 0:
        print(counter)
    counter += 1
e_letter = 'e'
for person in persons_list:
    if e_letter in person['name'].lower():
        lower_person = person['name'].lower()
        if lower_person.startswith(e_letter):
            print(f'{e_letter} in index 0')
        elif lower_person[1] == e_letter:
            print(f'{e_letter} in index 1')
        else:
            print(f"{e_letter} in index {person['name'].find(e_letter)}")
<mask token>
time = int(input('Enter time in minutes'))
hours = int(time / 60)
minutes = time - hours * 60
print(f'hours: {hours}, minutes: {minutes}')
if hours >= 1:
    if hours < 2:
        print('Ok...')
    else:
        print('Trilogy')
if minutes > hours:
    if minutes % 2 == 0:
        hours *= 2
    else:
        minutes -= 1
else:
    print(hours)
print(f'Hours: {hours}, Minutes: {minutes}')
<mask token>
file_content = """
My my candle candle burns at both ends;
It will not last the night;
But ah, my foes, and oh, my friends—
It gives a lovely light!
"""
file_path = 'file.txt'
with open(file_path, mode='w') as my_file:
    my_file.write(file_content)
with open(file_path, mode='r') as my_file:
    reading_content = my_file.read()
all_words = reading_content.split()
all_words_set = set({})
for word in all_words:
    word = re.sub('[^A-Za-z]+', '', word)
    all_words_set.add(word.lower())
for word in all_words_set:
    if word.startswith('t'):
        print(f"Word ({word}) starts with 't'")
for word in all_words_set:
    if word.lower().startswith('a'):
        print(f'Word: {word}')
        print('Letters:')
        for letter in word:
            print(letter)
words_tuple = tuple(word for word in all_words if 'a' not in word.lower())
print(words_tuple)
to_be_tuple = []
for word in all_words:
    if 'a' not in word.lower():
        to_be_tuple.append(word)
to_be_tuple = tuple(to_be_tuple)
print(to_be_tuple)
new_e_words = [e_word.replace('e', '3') for e_word in all_words_set if 'e' in
    e_word]
print(new_e_words)
e_to_3 = []
for word in all_words_set:
    if 'e' in word:
        new_word = word.replace('e', '3')
        e_to_3.append(new_word)
print(e_to_3)

import re
<mask token>
persons_list = []
for index in range(1, 4):
    print(f'Person number {index}:')
    person = {'name': input('Enter your name\n'), 'age': int(input(
        'Enter your age\n'))}
    persons_list.append(person)
for person in persons_list:
    if person['age'] < 27:
        person['name'] = 'Jimmy Hendrix'
print(persons_list)
for person in persons_list:
    if 't' in person['name'].lower():
        person['age'] += 1
        print(
            f"Happy bday {person['name']}\nYour are {person['age']} years old."
            )
counter = 0
while counter < persons_list[0]['age']:
    if not counter % 2 == 0:
        print(counter)
    counter += 1
e_letter = 'e'
for person in persons_list:
    if e_letter in person['name'].lower():
        lower_person = person['name'].lower()
        if lower_person.startswith(e_letter):
            print(f'{e_letter} in index 0')
        elif lower_person[1] == e_letter:
            print(f'{e_letter} in index 1')
        else:
            print(f"{e_letter} in index {person['name'].find(e_letter)}")
<mask token>
time = int(input('Enter time in minutes'))
hours = int(time / 60)
minutes = time - hours * 60
print(f'hours: {hours}, minutes: {minutes}')
if hours >= 1:
    if hours < 2:
        print('Ok...')
    else:
        print('Trilogy')
if minutes > hours:
    if minutes % 2 == 0:
        hours *= 2
    else:
        minutes -= 1
else:
    print(hours)
print(f'Hours: {hours}, Minutes: {minutes}')
<mask token>
file_content = """
My my candle candle burns at both ends;
It will not last the night;
But ah, my foes, and oh, my friends—
It gives a lovely light!
"""
file_path = 'file.txt'
with open(file_path, mode='w') as my_file:
    my_file.write(file_content)
with open(file_path, mode='r') as my_file:
    reading_content = my_file.read()
all_words = reading_content.split()
all_words_set = set({})
for word in all_words:
    word = re.sub('[^A-Za-z]+', '', word)
    all_words_set.add(word.lower())
for word in all_words_set:
    if word.startswith('t'):
        print(f"Word ({word}) starts with 't'")
for word in all_words_set:
    if word.lower().startswith('a'):
        print(f'Word: {word}')
        print('Letters:')
        for letter in word:
            print(letter)
words_tuple = tuple(word for word in all_words if 'a' not in word.lower())
print(words_tuple)
to_be_tuple = []
for word in all_words:
    if 'a' not in word.lower():
        to_be_tuple.append(word)
to_be_tuple = tuple(to_be_tuple)
print(to_be_tuple)
new_e_words = [e_word.replace('e', '3') for e_word in all_words_set if 'e' in
    e_word]
print(new_e_words)
e_to_3 = []
for word in all_words_set:
    if 'e' in word:
        new_word = word.replace('e', '3')
        e_to_3.append(new_word)
print(e_to_3)

import re

"""
First Task
"""

# Initial Persons
persons_list = []

for index in range(1, 4):

    print(f"Person number {index}:")

    person = {
        'name': input('Enter your name\n'),
        'age': int(input('Enter your age\n'))
    }
    persons_list.append(person)


# 1)
for person in persons_list:
    if person['age'] < 27:
        person['name'] = 'Jimmy Hendrix'

print(persons_list)

# 2)
for person in persons_list:
    if 't' in person['name'].lower():
        person['age'] += 1
        print(f"""Happy bday {person['name']}
Your are {person['age']} years old.""")

# 3)
counter = 0

while counter < persons_list[0]['age']:
    if not counter % 2 == 0:
        print(counter)
    counter += 1

# 4)
e_letter = 'e'

for person in persons_list:
    if e_letter in person['name'].lower():

        lower_person = person['name'].lower()

        if lower_person.startswith(e_letter):
            print(f"{e_letter} in index 0")
        elif lower_person[1] == e_letter:
            print(f"{e_letter} in index 1")
        else:
            print(f"{e_letter} in index {person['name'].find(e_letter)}")

"""
Second Task
"""

# Initial Time
time = int(input('Enter time in minutes'))

# 1)
hours = int(time / 60)
minutes = time - (hours * 60)

print(f"hours: {hours}, minutes: {minutes}")

# 2)
if hours >= 1:
    if hours < 2:
        print("Ok...")
    else:
        print("Trilogy")

# 3)
if minutes > hours:
    if minutes % 2 == 0:
        hours *= 2
    else:
        minutes -= 1
else:
    print(hours)

print(f"Hours: {hours}, Minutes: {minutes}")

"""
Third Task
"""

# Creating the file

file_content = """
My my candle candle burns at both ends;
It will not last the night;
But ah, my foes, and oh, my friends—
It gives a lovely light!
"""

file_path = "file.txt"

with open(file_path, mode='w') as my_file:
    my_file.write(file_content)

# Reading the file

with open(file_path, mode='r') as my_file:
    reading_content = my_file.read()


# 1)
all_words = reading_content.split()

# 2)
all_words_set = set({})

#
for word in all_words:
    word = re.sub(r"[^A-Za-z]+", "", word)
    all_words_set.add(word.lower())

# 3)
for word in all_words_set:
    if word.startswith('t'):
        print(f"Word ({word}) starts with 't'")

# 4)
for word in all_words_set:
    if word.lower().startswith('a'):
        print(f"Word: {word}")
        print("Letters:")
        for letter in word:
            print(letter)

# 5) Short way
words_tuple = tuple(word for word in all_words if 'a' not in word.lower())
print(words_tuple)

# 5) Long way
to_be_tuple = []
for word in all_words:
    if 'a' not in word.lower():
        to_be_tuple.append(word)

to_be_tuple = tuple(to_be_tuple)
print(to_be_tuple)

# 6) Short way
new_e_words = [e_word.replace('e', '3') for e_word in all_words_set if 'e' in e_word]
print(new_e_words)

# 6) Long way
e_to_3 = []

for word in all_words_set:
    if 'e' in word:
        new_word = word.replace('e', '3')
        e_to_3.append(new_word)

print(e_to_3)

