Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Escape indentation
#2
On line 15 you are callingis_prime_v1(n)a second time. Try it like this:
prime = []
def is_prime_v1(n):
     
    if n == 1:
     return False
     
    for d in range(2, n):
        if n % d == 0:
            return False
    prime.append(n)
    return n
   
for n in range(1,21):
  prime_number = is_prime_v1(n)
  if prime_number != False:
    print(prime_number)
    
print(prime)  
Frankduc likes this post
Reply


Messages In This Thread
Escape indentation - by Frankduc - Jan-28-2022, 02:25 PM
RE: Escape indentation - by BashBedlam - Jan-28-2022, 02:53 PM
RE: Escape indentation - by Frankduc - Jan-28-2022, 03:05 PM
RE: Escape indentation - by snippsat - Jan-28-2022, 03:13 PM
RE: Escape indentation - by Frankduc - Jan-28-2022, 03:36 PM
RE: Escape indentation - by Gribouillis - Jan-28-2022, 03:41 PM
RE: Escape indentation - by Frankduc - Jan-28-2022, 04:07 PM
RE: Escape indentation - by deanhystad - Jan-28-2022, 04:24 PM
RE: Escape indentation - by Frankduc - Jan-28-2022, 04:50 PM
RE: Escape indentation - by deanhystad - Jan-28-2022, 07:24 PM
RE: Escape indentation - by Gribouillis - Jan-28-2022, 09:59 PM
RE: Escape indentation - by Frankduc - Jan-31-2022, 02:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  use of escape character in re.sub and find WJSwan 1 961 Feb-16-2023, 05:19 PM
Last Post: Larz60+
  add Escape charcters in string GrahamL 3 1,242 Jan-20-2022, 01:15 PM
Last Post: GrahamL
  Escape Single quotation between each content tag usman 3 2,912 May-02-2021, 03:32 PM
Last Post: snippsat
  DIY Escape Room for fun StannemanPython 1 2,387 Feb-17-2021, 10:53 PM
Last Post: maurom82
  How to escape OrderedDict as an argument? Mark17 2 2,089 Dec-23-2020, 06:47 PM
Last Post: Mark17
  help for escape sequences NewPi 1 2,089 Dec-11-2019, 11:22 PM
Last Post: ichabod801
  escape single quote deep_logic 1 1,851 Sep-10-2019, 08:05 PM
Last Post: SheeppOSU
  The use of escape char \ hishamzero1 2 2,437 Aug-12-2019, 10:20 PM
Last Post: hishamzero1
  Escape sequences display in python Uchikago 1 2,493 Jun-27-2019, 03:25 PM
Last Post: Gribouillis
  Python 3 escape codes oldDog 1 2,650 Sep-15-2018, 10:12 AM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020