Skip to main content
2 of 2
Adding language title
Victor Stafusa
  • 8.8k
  • 5
  • 40
  • 61

Python 3

Example from real-life (translated to english). One of the python3 student tasks was writing a program that outputs string with user name to both screen and file. The student program was:

protocol_file = open("protocol.txt", "wt")
name = input("Enter your name: ")
print(protocol_file.write("Judge says:  Do you admit your guilt, " + name + "?\n"))
protocol_file.close()

For testing purposes student inputs some two-letter garbage as name - "mg". ... and, got 42 printed in console.