Python Forum
Struggling with variables
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Struggling with variables
#1
Hey I am studying Python new to it and trying to write a program short code that checks which numbers divide evenly into 1241... tried this but just cant get the variables right. Also studying algebra beginners.
n=0
i = 0
n=0
for i in range(0,1241):
    if (n%i == 0):
        print(i,"divides evenly into",n)
idk if it needs a counter.. i am so lost
Thanks

Fixed it now:


n=1241
i = 0
for i in range(1,1242):
    if (n%i) == 0:
        print(i,"divides evenly into",n)
Reply


Messages In This Thread
Struggling with variables - by pythonstudy00 - Sep-23-2020, 04:54 AM
RE: Struggling with variables - by DPaul - Sep-23-2020, 06:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Struggling on Tuples Mystix 3 4,938 Feb-01-2021, 06:06 PM
Last Post: nilamo
  Struggling To Understand These 2 Python Files samlee916 2 1,814 Sep-22-2020, 04:50 AM
Last Post: ndc85430
  struggling w/ fonctions in Python Tiril123 7 3,894 May-09-2020, 10:51 AM
Last Post: pyzyx3qwerty
  struggling with one part of python Lucifer 23 6,941 May-08-2020, 12:24 PM
Last Post: pyzyx3qwerty
  struggling with python save/load function newatpython00 1 2,028 Nov-15-2019, 07:58 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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