Code Snippets


Main Method

Remember, this goes at the end of every file with a main() method:

if __name__ == "__main__":
    main()

File I/O demonstration

# print every line from test.txt

f = open("test.txt", "r")
lines = f.readlines()
for line in lines:
    print(line.strip())