Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
None problem
#1
def printbeam():
    print('+----')

def printtwice():
    for i in range(2):
        printbeam()

print(printtwice())
I'm halfway through my code and the output is this:

Output:
+---- +---- None
Everything's great except this 'None' that is intruding everything.
Reply
#2
You are calling the function from a print() function, which expects a return value, doesn't receive one, so prints a default of None.

def printbeam():
    print('+----')
 
def printtwice():
    for _ in range(10):
        printbeam()
    return 'hello'
 
print(printtwice())
Return something, all call directly without print().
I am trying to help you, really, even if it doesn't always seem that way
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020