Skip to content

Instantly share code, notes, and snippets.

@altilunium
Created December 8, 2023 12:59
Show Gist options
  • Save altilunium/27eadc58f2e25566c3315919c2400ab4 to your computer and use it in GitHub Desktop.
Save altilunium/27eadc58f2e25566c3315919c2400ab4 to your computer and use it in GitHub Desktop.
# Specify the file path
file_path = 'a1.txt'
zatot = 0
# Open the file in read mode
with open(file_path, 'r') as file:
# Process each line in the file
for line in file:
# Do something with the line (replace this with your processing logic)
processed_line = line.strip() # Removing leading and trailing whitespaces
zanum = ""
for c in processed_line:
if c.isdigit():
zanum = zanum + c
break
for c in reversed(processed_line):
if c.isdigit():
zanum = zanum + c
break
zanum = int(zanum)
zatot = zatot +zanum
print(processed_line) # Print the processed line as an example
print(zanum)
print(zatot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment