subject

Write a program named palindromefinder. py which takes two files as arguments. The first file is the input file which contains one word per line and the second file is the output file. The output file is created by finding and outputting all the palindromes in the input file. A palindrome is a sequence of characters which reads the same backwards and forwards. For example, the word 'racecar' is a palindrome because if you read it from left to right or right to left the word is the same. Let us further limit our definition of a palindrome to a sequence of characters greater than length 1. A sample input file is provided named words_shuffled. The file contains 235,885 words. You may want to create smaller sample input files before attempting to tackle the 235,885 word sample file. Your program should not take longer than 5 seconds to calculate the output In Python 3,
MY CODE: palindromefinder. py
import sys
def is_Palindrome(s):
if len(s) > 1 and s == s[::-1]:
return true
else:
return false
def main():
if len(sys. argv) < 2:
print('Not enough arguments. Please provide a file')
exit(1)
file_name = sys. argv[1]
list_of_palindrome = []
with open(file_name, 'r') as file_handle:
for line in file_handle:
lowercase_string = string. lower()
if is_Palindrome(lowercase_string):
list_of_palindrome. append(string)
else:
print(list_of_palindrome)
If you can adjust my code to get program running that would be ideal, but if you need to start from scratch that is fine.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:50
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
question
Computers and Technology, 22.06.2019 10:20
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
question
Computers and Technology, 22.06.2019 17:30
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
question
Computers and Technology, 23.06.2019 00:10
My has been slow anyone else’s ?
Answers: 1
You know the right answer?
Write a program named palindromefinder. py which takes two files as arguments. The first file is the...
Questions
question
Mathematics, 20.09.2019 04:30
question
Physics, 20.09.2019 04:30
Questions on the website: 13722363