Collatz sequence, how should None be disposed of in the final return value

beginners need to write Collatz sequences when learning Python, chapters, and then write such code themselves

< H1 > this is a code exercise about Collatz sequences < / H1 >

print ("Enter number:")
def Collatz ():

try:
    num = int(input())
    while num !=1 :
        if num %2 == 0:
            num = num // 2
            print(num)
        elif num %2 == 1:
            num = 3*num+1
            print(num)
except ValueError:
    print("Error! Please Enter number")

print (Collatz ())

Enter number:
5
16
8
4
2
1
None

None, appears unexpectedly in the return value above. I want to ask which point in the code caused this None, and how should it be removed?
having tried if num = = 1 sys.exit breakbreakor calling

before will not solve the problem.
Mar.30,2021

because of your sentence:

print(collatz())

collatz as a function, it returns None by default if no value is returned. This None is printed out by the print () function.
so you can just do this:

collatz()
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf4a0f-31f26.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf4a0f-31f26.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?