Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loop question(skipping)
#1
Hi guys

I'm new in Python so i have an question.
My code work but i know that it's very very bad way to do it.I don't know what is best way to skip big number in for loop

My code:

first = ["a", "b", "c", "d", "e", "f", "g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","!","-","_","0","1","2","3","4","5","6","7","8","9","."]

    keywords = map(''.join, product(first, repeat=x))
    for key in keywords:
        asd += 1
        if (asd > 100000000):
I'm doing this to skip for loop 100000000 times...It's bad,i know..But what is faster way to skip it? I need to skip big number,because i don't know other way..

Thank you
Reply
#2
you can use:
import string

first = list(string.printable)
to get the list, sans the , but still accessible as char = first[n]
you don't show what product is, so can't run snippet.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  File loop curiously skipping files - FIXED mbk34 10 787 Feb-10-2024, 07:08 AM
Last Post: buran
  Skipping line in text without Restarting Loop IdMineThat 4 1,475 Apr-05-2022, 04:23 AM
Last Post: deanhystad
  A question about 'Event loop is closed' fc5igm 2 2,201 Oct-05-2021, 02:00 AM
Last Post: fc5igm
Exclamation question about input, while loop, then print jamie_01 5 2,649 Sep-30-2021, 12:46 PM
Last Post: Underscore
  python seems to be skipping lines of code alansandbucket 1 4,148 Jun-22-2021, 01:18 AM
Last Post: Larz60+
  for loop question KEYS 1 1,722 Oct-27-2020, 11:42 PM
Last Post: jefsummers
  Netmiko Loop question sc00ter 2 3,309 Oct-24-2020, 10:54 PM
Last Post: sc00ter
  while loop question KEYS 2 2,011 Sep-26-2020, 11:02 PM
Last Post: KEYS
  New to programming, loop question tomyan 1 1,632 Sep-25-2020, 04:32 PM
Last Post: Larz60+
  while loop question spalisetty06 2 1,845 Aug-13-2020, 04:18 PM
Last Post: buran

Forum Jump:

User Panel Messages

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