Python Forum
why it doesn`t stop at first double numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why it doesn`t stop at first double numbers
#4
I think I understand what you want your program to do. But I am not 100% sure.
Actually, I think your program may be working fine. What is confusing could be a lot of prints.
In each loop, there is:
    print(copy) #  previous number
    number = random.randint(1, mnum)
    print(number)  # current number
So you need to check result in pairs, example:
Output:
(first iteration) 2 1 (second iteration) 1 2 (third iteration) 2 2 (two in a row).
Maybe try printing like this:

# ... code before

while tryes < repeats :
    copy = number
    print("previous number: ", copy)
    number = random.randint(1, mnum)
    print("current number: ", number)
    print("-------")

# code after ...
Did this help? Please clarify more if I didn't answer your question.
Reply


Messages In This Thread
RE: why it doesn`t stop at first double numbers - by j.crater - Mar-24-2020, 06:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  len() function, numbers doesn't work with Geany Editor Penguin827 3 3,174 May-08-2020, 04:08 AM
Last Post: buran
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,944 May-09-2019, 12:19 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

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