-6

How does one print the lines of code?

Suppose we have here two variables.

var1 = 2*8
msg = "Answer is: "

What statement should i add here so that this program will print the source code?

omni
  • 580
  • 1
  • 6
  • 16
  • print var1 this will the print the value of var1 – lakshmen Oct 04 '14 at 04:29
  • I'm not quite sure what you're asking. Maybe provide sample output and define your question better? – omni Oct 04 '14 at 04:30
  • @lakesh I know how to print the values stored in the variables, i wanted to know what command will print me the codes i used when writing the program. – Larry Awton Oct 04 '14 at 04:48

1 Answers1

0

The easiest way to print the lines of codes is through the use of the built-in functions.

   print open(__file__).read()

Or you could just write the code in string mode and simply print them. However that obviously won't be executable codes anymore once written in quotation marks.