Last active
February 17, 2021 07:29
-
-
Save Deniz97/b3157636aee3e0368a2ddcb2c907b374 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("sample_prices.txt", "r") as myfile: | |
all = myfile.readlines() | |
prices = [ ] | |
for line in all: | |
l = line.split(":") | |
prices.append( (l[0], l[1] )) | |
counter = 1 | |
memory = [prices[0][0]] | |
current_price = prices[0][1] | |
for p in prices[1:]: | |
if p[1] == current_price: | |
counter += 1 | |
if counter < 3: | |
memory.append(p[0]) | |
elif counter == 3: | |
print() | |
for m in memory: | |
print(m) | |
print(p[0]) | |
elif counter > 3: | |
print(p[0]) | |
else: | |
memory = [p[0]] | |
counter = 1 | |
current_price = p[1] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment