How do I iterate through the alphabet?
You can use string.ascii_lowercase
which is simply a convenience string of lowercase letters,
>>> from string import ascii_lowercase>>> for c in ascii_lowercase:... # append to your url
In addition to string.ascii_lowercase
you should also take a look at the ord
and chr
built-ins. ord('a')
will give you the ascii value for 'a'
and chr(ord('a'))
will give you back the string 'a'
.
Using these you can increment and decrement through character codes and convert back and forth easily enough. ASCII table is always a good bookmark to have too.
I cannot comment, so I just want to give a code to @Brian answer. https://stackoverflow.com/a/17182751/1425790
url=www.website.com/termmy_char=ord('a') # convert char to asciiwhile my_char<= ord('z'): my_char+=1 # iterate over abc my_url=url+chr(my_char) # convert ascii to char do_something(my_url)