Aug-27-2021, 08:34 PM
(Aug-27-2021, 07:42 PM)Teknohead23 Wrote: If I use a while loop, which I think I should, I get an infinite loop as it will always be trueA for loop is always the first choice in Python,here a example with
enumerate
and f-string which you should use. import os letters = input("Enter the first 3 letters : ").upper() num_start = 1 for index,item in enumerate(letters, num_start): dir_look = fr"C:\Users\user\Documents\Client Drawings\{letters}{index:03}" print(dir_look) check_for_folder = os.path.isdir(dir_look) print(check_for_folder
Output:Enter the first 3 letters : aaa
C:\Users\user\Documents\Client Drawings\AAA001
False
C:\Users\user\Documents\Client Drawings\AAA002
False
C:\Users\user\Documents\Client Drawings\AAA003
False