Skip to content

Instantly share code, notes, and snippets.

@hygull
Created January 2, 2019 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hygull/a2d5fb226a60b16b946196b554108ff4 to your computer and use it in GitHub Desktop.
Save hygull/a2d5fb226a60b16b946196b554108ff4 to your computer and use it in GitHub Desktop.

file1.txt

text1
text2
text3

file2.txt

1985
1986
1987

reader.py

	with open('file1.txt') as f1_text:
		texts = f1_text.readlines();

	with open('file2.txt') as f2_year:
		years = f2_year.readlines()

	for text in texts:
		text = text.strip()
		for year in years:
			year = year.strip()
			print('%s: %s' % (text, year))

	# RISHIKESH@CodingPC MINGW64 /e/Users/Rishikesh/Projects/Python3/try/problem_stk1
	# $ python reader.py
	# text1: 1985
	# text1: 1986
	# text1: 1987
	# text2: 1985
	# text2: 1986
	# text2: 1987
	# text3: 1985
	# text3: 1986
	# text3: 1987
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment