Python: Function that reads file numbers.txt and outputs numbers-mult.txt where each number in numbers.txt is multiplied by its line number. — # don't use os.linesep def main(): input_file = "numbers.txt" output_file = "numbers-mult.txt" output = [] with open(input_file, "r") as input_handle: for line_number, line in enumerate(input_handle, 1): output.append(line_number * int(line.rstrip())) output_handle = open(output_file, "w") output_handle.write('\n'.join(str(n) for n in output))
G
1.2K
Google Interview
This flashcard deck made by jwasham contains knowledge about google interview. For more details, please follow https://github.com/jwasham/google-interview-university