Python Forum
Please help my while loop does not work as expected
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help my while loop does not work as expected
#5
I edited my while loop to include the x:
unit = int(input("Please enter the unit: "))
mod = int(input("Please enter the mod: "))
count = 1
x = unit%mod
while x != 1:
    count = count +1
    unit = unit * count
    x = unit%mod
else:
    print("The inverse is: ", count)
Still does not seem to exit the while loop
Reply


Messages In This Thread
RE: Python - by bowlofred - Sep-28-2020, 07:12 PM
RE: Python - by KingKhan248 - Sep-28-2020, 07:29 PM
RE: Python - by bowlofred - Sep-28-2020, 07:49 PM
RE: Please help my while loop does not work as expected - by KingKhan248 - Sep-28-2020, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extending list doesn't work as expected mmhmjanssen 2 231 May-09-2024, 05:39 PM
Last Post: Pedroski55
  While Loop Does Not Work Properly mactron 4 983 Jun-22-2023, 01:04 AM
Last Post: mactron
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,088 Dec-18-2021, 02:38 AM
Last Post: knight2000
  How can this for loop work without : ? Pedroski55 1 1,737 Dec-13-2020, 01:19 AM
Last Post: palladium
  For loop in my __init__ doesn't work as expected Jessy 2 2,419 Nov-18-2019, 10:07 AM
Last Post: buran
Question Why does modifying a list in a for loop not seem to work? umut3806 2 2,348 Jul-22-2019, 08:25 PM
Last Post: umut3806
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 3,260 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619
  for loop just work one Faruk 1 2,046 Jan-19-2019, 05:34 PM
Last Post: Larz60+
  'Looping' does not work out within a 'for Loop' Placebo 4 3,422 Sep-15-2018, 08:19 PM
Last Post: Placebo
  Having issues getting a loop to work PLESSE HELP ASAP manthus007 1 2,162 Aug-25-2018, 10:44 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

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