Why does "none" show? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Why does "none" show?

"none" shows before each number in output when I use time.sleep(1) in print function. how come? how can I fix this? import time i = 0 while 1==1: print(time.sleep(1),i) i = i + 1 if i >= 6: break f = 6 while 6>-1: print(time.sleep(1),f) f = f -1 if f == -1: print("Finished") break

24th Feb 2018, 7:18 AM
Derek Warwick
Derek Warwick - avatar
3 Answers
+ 5
One does not simply print time.sleep() it's a void method that returns none
24th Feb 2018, 8:04 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
if you just want it to cout to 6 and then back to 0 remove time.sleep(1) from print and put it on the line above the print statement.
24th Feb 2018, 8:24 AM
emmey
emmey - avatar
+ 1
@emmey thanks that works
24th Feb 2018, 8:29 AM
Derek Warwick
Derek Warwick - avatar