Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 List creation and return in Function
#1

def factors(x):
   L = []
   for i in range(1, x + 1):
       if x % i == 0:
            L.append(i)
    return L


num = 84


print (factors(num))

I'm trying to return a list in this function. Python gives me an error "IndentationError: unindent does not match any outer indentation level"

Could someone help me fix it? Many thanks in advance!
Quote
#2
Line 6 is not properly indented.
Quote
#3
Your indentation is all over the place.
At lines 2 and 3, it starts with 3 spaces, and then continues with 7, 12, and 4.
Quote
#4
Thank you every one!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [SOLVED ]ValueError: View function did not return a response Hadad 0 105 Jul-24-2019, 04:01 PM
Last Post: Hadad
  reading txt file putting in list function Expel 7 176 Jul-17-2019, 03:18 PM
Last Post: Expel
  Why does this return False? gunitinug 1 97 Jul-13-2019, 07:11 AM
Last Post: perfringo
  Need help with 'return' in python Leo12143 2 276 Jul-10-2019, 02:35 AM
Last Post: SheeppOSU
  generator function that yield from a list buran 9 457 Jun-04-2019, 10:26 PM
Last Post: snippsat
  Search a List of Dictionaries by Key-Value Pair; Return Dictionary/ies Containing KV dn237 19 590 May-29-2019, 02:27 AM
Last Post: heiner55
  python 2D array creation and print issue developerbrain 5 223 May-15-2019, 01:38 PM
Last Post: developerbrain
  folder PyQt5 created during creation exe atlass218 0 157 Apr-26-2019, 06:25 PM
Last Post: atlass218
  Creation of Dynamic HTML by substituting Database values Sandy777 1 227 Apr-18-2019, 07:17 AM
Last Post: buran
  AssertionError: View function mapping is overwriting an existing endpoint function Zhavi221 7 1,178 Apr-17-2019, 01:07 PM
Last Post: Zhavi221

Forum Jump:


Users browsing this thread: 1 Guest(s)