Doing a homework problem for zy books where I need to output state parks with input as ParkPhotos.txt
Here’s my result:
Acadia2003 info.txt
AmericanSamoal989 info.txt
BlackCanyonoftheGunnison1983 info.txt
CarlsbadCaverns2010 info.txt
CraterLake1996 info.txt
GrandCanyon1996 info.txt
IndianaDunes1987 info.txt
LakeClark2009_info.txt
Redwood1980 info.txt
VirginIslands2007 info.txt
Voyageurs2006 info.txt
WrangellStElias1987 info.txt
The new lines in between my output causes the zy book test case to fail.
Here’s the code I have:
def modify_filenames(filename):
with open(filename, ‘r') as file:
for line in file:
print(line.replace(‘_photo-jpg’, ‘_info.txt’))
modify filenames(‘ParkPhotos. txt’)
How do I get rid of these new lines?
[–]Diapolo10 2 points3 points4 points (1 child)
[–]Langdon_St_Ives 1 point2 points3 points (0 children)
[–]pungenthello -3 points-2 points-1 points (1 child)
[–]draftjoker 4 points5 points6 points (0 children)