forked from miczar1/djfz-24_25
Added folders TaskC00 to TaskC48
This commit is contained in:
parent
dcdcad4cf6
commit
240f1b0973
15
TaskA02/solution.py
Normal file
15
TaskA02/solution.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# File path to read
|
||||||
|
file_path = 'text.txt'
|
||||||
|
|
||||||
|
# Open the file and search for lines containing the word "pies"
|
||||||
|
with open(file_path, 'r') as file:
|
||||||
|
lines_with_pies = []
|
||||||
|
for line in file:
|
||||||
|
# Split the line into words and check for the word "pies" (case-insensitive)
|
||||||
|
words = line.strip().lower().split()
|
||||||
|
if 'pies' in words:
|
||||||
|
lines_with_pies.append(line.strip())
|
||||||
|
|
||||||
|
# Display the results
|
||||||
|
for line in lines_with_pies:
|
||||||
|
print(line)
|
25
TaskA04/solution.py
Normal file
25
TaskA04/solution.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# File path to read
|
||||||
|
file_path = 'text.txt'
|
||||||
|
|
||||||
|
# List to store all digit substrings
|
||||||
|
digit_substrings = []
|
||||||
|
|
||||||
|
# Open the file and read line by line
|
||||||
|
with open(file_path, 'r') as file:
|
||||||
|
for line in file:
|
||||||
|
current_digits = ""
|
||||||
|
# Loop through each character in the line
|
||||||
|
for char in line:
|
||||||
|
if char.isdigit(): # Check if the character is a digit
|
||||||
|
current_digits += char # Add to current digit substring
|
||||||
|
else:
|
||||||
|
if current_digits: # End of a digit substring
|
||||||
|
digit_substrings.append(current_digits)
|
||||||
|
current_digits = "" # Reset current_digits for next substring
|
||||||
|
|
||||||
|
# Append any remaining digits at the end of the line
|
||||||
|
if current_digits:
|
||||||
|
digit_substrings.append(current_digits)
|
||||||
|
|
||||||
|
# Print the result as space-separated substrings
|
||||||
|
print(" ".join(digit_substrings))
|
0
skrypcik.py
Normal file
0
skrypcik.py
Normal file
Loading…
Reference in New Issue
Block a user