Bottom Page

Thread Rating:
• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 List creation and return in Function leoahum Silly Frenchman Posts: 29 Threads: 10 Joined: Oct 2018 Reputation: 0 Likes received: 0 #1 Mar-04-2019, 04:12 PM ``` 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! Olivier Programmer named Tim Posts: 6 Threads: 1 Joined: Mar 2019 Reputation: 0 Likes received: 0 #2 Mar-04-2019, 04:25 PM Line 6 is not properly indented. stranac A Beautiful Pony Posts: 262 Threads: 6 Joined: Nov 2016 Reputation: 14 Likes received: 114 #3 Mar-04-2019, 04:31 PM (This post was last modified: Mar-04-2019, 04:32 PM by stranac. Edited 1 time in total.) 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. leoahum Silly Frenchman Posts: 29 Threads: 10 Joined: Oct 2018 Reputation: 0 Likes received: 0 #4 Mar-04-2019, 04:45 PM Thank you every one! « Next Oldest | Next Newest »

Top Page

 Possibly Related Threads... Thread Author Replies Views Last Post How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 5 246 Nov-21-2019, 09:02 PM Last Post: Pleiades I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 148 Oct-12-2019, 08:02 PM Last Post: mrhopeedu Custom Function to Return Database Values rm78 0 142 Sep-05-2019, 01:01 PM Last Post: rm78 [SOLVED ]ValueError: View function did not return a response Hadad 0 497 Jul-24-2019, 04:01 PM Last Post: Hadad Search a List of Dictionaries by Key-Value Pair; Return Dictionary/ies Containing KV dn237 19 832 May-29-2019, 02:27 AM Last Post: heiner55 Return all Path value from function Palerm0_24 2 360 Mar-18-2019, 03:09 PM Last Post: ichabod801 List Creation sunnyarora 3 428 Mar-15-2019, 11:05 PM Last Post: farhan275 Function to return modified list Pjones006 2 359 Feb-06-2019, 10:57 PM Last Post: Pjones006 Function and return value Roh_80 1 404 Jan-24-2019, 03:15 PM Last Post: buran how to use the return function NLittle17 5 653 Jan-08-2019, 12:01 AM Last Post: ichabod801

Forum Jump:

Users browsing this thread: 1 Guest(s)