Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filenames = ["program.c", "stdio.hpp", "sample.hpp", "a.out", "math.hpp", "hpp.out"]
- newfilenames = []
- for filename in filenames:
- if filename.endswith("hpp"):
- newfilenames.append((filename, filename.replace("hpp", "h")))
- else:
- newfilenames.append((filename, filename))
- print (newfilenames) # Should be [('program.c', 'program.c'), ('stdio.hpp', 'stdio.h'), ('sample.hpp', 'sample.h'), ('a.out', 'a.out'), ('math.hpp', 'math.h'), ('hpp.out', 'hpp.out')]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement