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, 23.06.2019 16:00
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
question
Computers and Technology, 25.06.2019 05:30
Your mother is sure that you were driving too fast because she knows a. when you arrived and the direction you came from. b. how long it took you to get home and how far you traveled. c. what time you left and how long it took you to get home. d. the direction you were driving and how far you traveled.
Answers: 2
question
Computers and Technology, 25.06.2019 10:10
Suppose you and your friend live on the same street d miles away from each other. between your house and your friend’s house there are n motorized scooters positioned at distances x1, x2, . . , xn miles from your house towards your friend’s house. each scooter has a battery that may or may not be fully charged. let’s say that the scooters can take you distances d1, d2, . . , dn miles down the road. each scooter also has a price p1, p2, . . , pn that it takes to activate. any time you encounter another scooter, you may take the new scooter and leave your old scooter behind. there is an additional scooter at your house that you start with and it can go distance d0 miles and it is free to activate: p0 = 0. you wish to go to your friend’s house minimizing the total amount of money spent activating the scooters. design a dynamic programming algorithm that returns the minimum cost to get to your friend’s house using scooters x0, . . , xn.
Answers: 1
question
Computers and Technology, 25.06.2019 17:00
Match each word to its correct meaning. 1. quick launch an area that displays icons representing open applications 2. shortcut an icon used to represent an application, a file, or a folder 3. start menu an area on the taskbar where icons representing programs that are always running are displayed 4. system tray a list of programs that can be opened by clicking on their names or icons 5. taskbar an area on the taskbar from which frequently used programs can be opened pls. will get brainlist
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
Arts, 31.03.2020 04:39
question
Mathematics, 31.03.2020 04:39
question
Mathematics, 31.03.2020 04:39
question
English, 31.03.2020 04:40
Questions on the website: 13722363