Note that there are some explanatory texts on larger screens.

plurals
  1. POthis code isn't printing as I want it to - python
    text
    copied!<p>With this code,I am not getting the kind of display I want.</p> <pre><code>def printTime(time): print time.hours,":",time.minutes,":",time.seconds, def makeTime(seconds): time = Time() print "have started converting seconds into hours and minutes" time.hours = seconds/3600 print "converted into hours and no.of hours is :",time.hours seconds = seconds - time.hours *3600 print "number of seconds left now:",seconds time.minutes = seconds/60 print "number of minutes now is :",time.minutes seconds = seconds - time.minutes*60 print "number of seconds left now is :",seconds time.seconds = seconds print "total time now is:",printTime(time) </code></pre> <p>The last line is causing the problem that is:</p> <pre><code>print "total time now is:",printTime(time) </code></pre> <p>I want the result to be in the format below- total time now is : 12:42:25</p> <p>but what i get is total time now is : 12:42:25 None</p> <p>but when I write that line as:</p> <pre><code>print "total time now is:" printTime(time) </code></pre> <p>then i get the result as - total time now is : 12:42:25</p> <p>The None thing doesn't appear when I dont write the printTime(time) function in the same line as print.</p> <p>So,what's really happening here? </p> <p>EDIT: I tried using the return statement, but the result was still the same. so,where exactly should I use the return statement. maybe i was using it incorrectly . i tried doing it as </p> <pre><code>print "total time now is:",return printTime(time) </code></pre> <p>but this gives an error.</p> <p>then I tried doing it this way -</p> <pre><code>print "total time now is:",printTime(time) return printTime(time) </code></pre> <p>still get the same result.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload