![]() |
Help!! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Help!! (/thread-41647.html) |
Help!! - prem_koresh_avraham - Feb-22-2024 def hint_username(username): if len(username) < 3: print("Invalid username. Usernames must have more than 3 characters") else: print("valid username") print (hint_username("charmingchand"))OUTPUT I would like to know why is none appearing here?
RE: Help!! - menator01 - Feb-22-2024 You are using print twice. Once in the function and when calling the function. Please use the bbtags when posting code. You should have a look at the help section on how to ask a question. Quick example: def afunc(arg): return arg def afunc2(arg): print(arg) print(afunc('I am using a return value and print')) afunc2('Callinga function that has a print') print(afunc2('Using both prints. This will return a None'))
RE: Help!! - paul18fr - Feb-22-2024 In addition to what it has previously said, that's the return content which is returned using print (None by default if not specified)def hint_username(username): if len(username) < 3: print("Invalid username. Usernames must have more than 3 characters") else: print("valid username") return None hint_username("charmingchand") hint_username("ff") print() # with print print(hint_username("\n")) print(hint_username("ddddddddddddddddddddddddd\n"))
|