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

  • SEARCH
  • Home
  • 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 8965827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:53:40+00:00 2026-06-15T16:53:40+00:00

for line in range(50): def show_table(): if len(table) == 0: print(‘There are no cards

  • 0
for line in range(50):
    def show_table():   

        if len(table) == 0: 
            print('There are no cards on the table.')   
        else:
            for card in range(len(table)):
                print names[table[card][0]] + ' played a ' + str(table[card][1]) + '.'
  • 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-15T16:53:42+00:00Added an answer on June 15, 2026 at 4:53 pm

    The first problem is that the colon goes at the end of the if condition, not after the word if. So:

    if len(table) == 0: print('There are no cards on the table.')
    

    Or, better:

    if len(table) == 0:
        print('There are no cards on the table.')
    

    However, testing this with both Python 2.7 and 3.3, I think you should actually be getting a SyntaxError, with the little caret pointing at the excess colon, rather than an error about indentation.

    Which implies that the actual error is that the line above it does something wrong as well.

    The next problem is that you can only use the one-liner shortcut with one colon, not two, so this:

    else: for card in range(len(table)): print names[table[card][0]] + ' played a ' + str(table[card][1]) + '.' ?
    

    Is just going to confuse the compiler. You really should break this up into idiomatic Python, rather than trying to see what you can get away with:

    for line in range(50):
    
        def show_table():
            if len(table) == 0:
                print('There are no cards on the table.')
            else:
                for card in range(len(table)):
                    print names[table[card][0]] + ' played a ' + str(table[card][1]) + '.' ?
    

    I’m not sure why you want to define a new function for each of 50 lines, and then never call that function, but this will at least be something legal… almost.

    The last problem is this:

    print names[table[card][0]] + ' played a ' + str(table[card][1]) + '.' ?
    

    First, print isn’t a statement in Python 3.3, it’s a regular old function, so you have to call it with arguments. Second, that ? at the end doesn’t seem to be attached to anything it could reasonably be attached to, so it’s probably a stray typo that needs to be fixed. So:

    print(names[table[card][0]] + ' played a ' + str(table[card][1]) + '.')
    

    Looking at the raw version of what you pasted into your edited question—this is just a guess, because you didn’t paste it as code—it looks like there may be two more problems.

    First, your first for line is indented 1 column. When you later come back to column 0, that’s counted as two dedents, not one.

    Second, the def show_table(): line is indented to column 8, but the next thing after it is back to column 0. Maybe you wanted an empty function here? If so, that’s not legal; in Python, functions can never be empty. But you can get the same effect with the pass statement:

    def show_table():
        pass
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm have this function: def ngrams(word): for i in range(1, len(word) + 1): yield
this is my code : a=[1,0,None,3] def b(my_list): for i in range(len(my_list)): if not
def suffix(stng): list = [] length = len(stng) for i in range(length): x =
VBA is throwing the above given error on the line Sheets(Sheet1).Range(A & i).Copy Destination:=Sheets(Sheet2).Range(A
Bottom Line Up Front Is there a succinct way that I can constrain the
i am doing this: def GetDistinctValues(theFile, theColumn): lines=theFile.split('\n') allValues=[] for line in lines: allValues.append(line[theColumn-1])
import sys def Hello(name): name = name + '!!!' print 'Hello' , name def
Here's the entirety of my code: import csv def numbersOut(): for i in range
#/usr/bin/python2.4 -tt import sys def mult_table(x,y): for i in range(1,y+1): for n in range(1,x+1):
def solve(numLegs, numHeads): for numChicks in range(0, numHeads + 1): numPigs = numHeads -

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.