Created
November 11, 2014 13:36
-
-
Save JanneSalokoski/18eedab73c06ea14b664 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
palindroms = [] | |
fileName = str(input("Anna luettavan tiedoston nimi: ")) | |
f = open(fileName, "r+") | |
for line in f: | |
for word in line.split(): | |
if word == word[::-1]: | |
palindroms.append(word) | |
f.close() | |
f = open("Palindromi.txt", "w") | |
if not palindroms: | |
f.write("Palindromeja ei löytynyt.\n") | |
else: | |
for word in palindroms: | |
f.write(word + "\n") | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment