[Tutor] Testing functions

dn PythonList at DancesWithMice.info
Mon Jun 26 08:53:48 EDT 2023


On 26/06/2023 22.16, Jack Simpson wrote:
> Hi.
> I have just been playing around with functions and wanted to know where
> should i be in putting variables to test out a function block i have
> written?
> 
> This one is just an example for demonstration but where should I be
> defining the value of username here to test the function?
> 
>>>> def hint_username(username):
> ...         if len(username) < 3:
> ...              print("Invalid username, must be at least 3 characters
> long")
> ...         else:
> ..   .           print("Valid username")

In the function-call, eg

hint_username( "Fred" )

Same as you would for len( string_identifier )

Isn't this covered in previous exchange?
(or have I misunderstood the question?)

-- 
Regards,
=dn


More information about the Tutor mailing list