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 3314632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:15:20+00:00 2026-05-17T22:15:20+00:00

Im working on a a sudoku program for python and i need some help.

  • 0

Im working on a a sudoku program for python and i need some help. The program will ask input from the user for 9 rows of numbers that hopefully contain the digits 1-9. Once they input all 9 rows the program should then go through each row and verify and see if it satisfies the conditions of a sudoku game. If it doesnt it will return a error message and display which row has an error. Now what i need help in is how to best check the rows without writing 9 different if statements. I need to incorporate a loop. How would i do this?

My progress in code so far is below:

from a5_import import *
import sys

sep = "-.-.-.-.-.-.-.-.-.-.-.-.-.-.-."

print sep

print " Sudoku Verifier! "

print sep

row_0=int(raw_input("Enter Row 0: "))

row_1=int(raw_input("Enter Row 1: "))

row_2=int(raw_input("Enter Row 2: "))

row_3=int(raw_input("Enter Row 3: "))

row_4=int(raw_input("Enter Row 4: "))

row_5=int(raw_input("Enter Row 5: "))

row_6=int(raw_input("Enter Row 6: "))

row_7=int(raw_input("Enter Row 7: "))

row_8=int(raw_input("Enter Row 8: ")) 

if not check9(row0):
print "Error: row 0 is invalid."

if not check9(row1):
    print "Error: row 1 is invalid."

if not check9(row2):
    print "Error: row 2 is invalid."

if not check9(row3):
    print "Error: row 3 is invalid."

if not check9(row4):
    print "Error: row 4 is invalid."

if not check9(row5):
    print "Error: row 5 is invalid."

if not check9(row6):
    print "Error: row 6 is invalid."

if not check9(row7):
    print "Error: row 7 is invalid."

if not check9(row8):
    print "Error: row 8 is invalid."     



print sep

Again the requirements are i need the following three things to be accomplished:

  1. The program produces the correct output
  2. The program uses a loop correctly to check the columns of the input.
  3. The program uses a loop correctly to check the boxes of the input.

Thanks for your help with the verifier loops.

  • 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-05-17T22:15:21+00:00Added an answer on May 17, 2026 at 10:15 pm

    Ok, I can see room for two loops in this scenario.

    LoopA a loop that gets the input and LoopB a loop that checks the output an example here:

    from a5_import import *
    import sys
    
    sep = "-.-.-.-.-.-.-.-.-.-.-.-.-.-.-."
    
    print sep
    
    print " Sudoku Verifier! "
    
    print sep
    
    rows = []
    
    for rowNum in range(1, 9):
        rowInput = int(raw_input("Enter Row %s: "% rowNum)) ## This is the same as int(raw_input("Enter Row +rowNum+": "))
        rows.append(rowInput) ##add the input to the list of rows
    
    for row in rows:
        if not check9(row):
            print "Row %s is not valid"% rows[rows.index(row)] ##Prints the row position number
    
    print sep
    

    The use of a list of rows would be the best bet for validation.

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

Sidebar

Related Questions

working on a website that will sell one item each day that will run
I'm trying to declare a function that will let me change a number in
Working on a method to allow users to attach a doc from their Google
Working with Visual Studio (I'm using 2008) I have started to notice that when
Working with Django docs' sample Blog and Entry models, how would one get a
Working with C# in .NET, I am trying to call IActiveScript.Close on my instance
working with iis7. project is in Integrated Pipelinemodus Application Pool is : DefaultAppPool have
Working with OpenGL, I used CreateWindow( app, App Window, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE
I am using EGit in eclipse to provide Git support for an Android project

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.