Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8947815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:51:48+00:00 2026-06-15T12:51:48+00:00

These are my two def functions: def valid_username(username): # implement the function here while

  • 0

These are my two def functions:

def valid_username(username):
     # implement the function here


    while True:

        try:
            username = input("Username: ")


            if len(username) < 8:
                print ("Sorry, the username must be at least 8 characters long.")


            if username.isalnum() == False:
                print ("Sorry, your name can only contain alpha numeric characters")


            numupper = 0


            for c in username:

                if c.isupper() == True:
                    numupper += 1

            if numupper > 0:
                print ("You have at least 1 uppercase in this username.")

            else:
                print ("You have no uppercase in this username.")

            numlower = 0

            for d in username:

                if d.islower() == True:
                    numlower +=1
            if numlower > 0:
                print ("You have at least 1 lowercase in this username.")

            else:
                print ("You have no lowercase in this username.")


            numdigit = 0

            for e in username:

                if e.isdigit() == True:
                    numdigit += 1
            if numdigit > 0:
                print ("You have at least one digit in this username.")

            else:
                print("You have no digits in this username.")

                continue

        except:
            print ("Sorry, not valid. Try again.")
        else:
            print ("Thank you for your input")
            break


def valid_password(password, username):
    # implement the function here

    while True:

        try:
            password = input("Password: ")

            if username in password:
                print ("That's not secure at all.")



            if len(password) < 8:
                print ("Sorry, the password must be at least 8 characters long.")


            if password.isalnum() == False:
                print ("Sorry, your password can only contain alpha numeric characters")


            numupper = 0


            for c in password:

                if c.isupper() == True:
                    numupper += 1

            if numupper > 0:
                print ("You have at least 1 uppercase in this password.")

            else:
                print ("You have no uppercase in this password.")

            numlower = 0

            for d in password:

                if d.islower() == True:
                    numlower +=1
            if numlower > 0:
                print ("You have at least 1 lowercase in this password.")

            else:
                print ("You have no lowercase in this password.")


            numdigit = 0

            for e in password:

                if e.isdigit() == True:
                    numdigit += 1
            if numdigit > 0:
                print ("You have at least one digit in this password.")

            else:
                print("You have no digits in this password.")

                continue

        except:
            print ("Sorry, not valid. Try again.")
        else:
            print ("Thank you for your input")
            break

my main program is this:

username = input("Username: ")


result, reason = uservalidation.valid_username(username)


if not(result):
    print (reason)


else:

    password = input("Password: ")


    pwresult, pwreason = uservalidation.valid_password(password, username)


    if not(pwresult):
        print (pwreason)
    else:
        print ("Username and Password combination is valid!")

when I run it I get the following:

Username: d
Username: user
Sorry, the username must be at least 8 characters long.
You have no uppercase in this username.
You have at least 1 lowercase in this username.
You have no digits in this username.
Username: craig2345
You have no uppercase in this username.
You have at least 1 lowercase in this username.
You have at least one digit in this username.
Thank you for your input
Traceback (most recent call last):
  File "C:/Users/Si Hong/Desktop/pythontest/HuangSiHong_Assign8_part3.py", line 7, in <module>
    result, reason = uservalidation.valid_username(username)
TypeError: 'NoneType' object is not iterable
>>> 

I’m having trouble figuring out why when I type enter in the first value for username, it doesn’t trigger the function, but does it after the 2nd time I enter it in, and also I am not sure how to solve the nonetype error issue, if someone can explain this to me, that would be great thank you so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:51:49+00:00Added an answer on June 15, 2026 at 12:51 pm

    If a function doesn’t have a value explicitly returned then it implicitly returns None, which cannot be applied to tuple unpacking this way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was learning ruby through ruby koans when I faced these two functions: def
How can I combine these two functions into one recursive function to have this
I have these two functions: def comparison(a, b): return [-1, 0, 1].index(cmp(b, a)) def
I have a class which is being operated on by two functions. One function
I have two functions like the following: def fitnesscompare(x, y): if x.fitness>y.fitness: return 1
I'm unable to determine why these two functions behave differently. I could just use
I have two def functions that I call in a nested fashion and want
Inside my view.py, I have two functions, one that processes input from a form
Here are two functions that split iterable items to sub-lists. I believe that this
Given these two snippets: def sex (code): return {'m': 'masculino', 'f': 'femenino', '': 'ignorado'}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.