I would like to find a string of certain length - example 7 characters. The string must only contain uppercase letters and numbers. I have ideas to: read the file line by line...
I am unsure the best practice here- read the whole file in one block or read the file line by line using a loop? Do you have to use a loop to read the file line by line?
# read lines in text file
filetoread=open("mytextfile.txt")
for lines in filetoread # right ?
#just an example of a given string of text (not from the file)
characters = "D123456"
for x in characters:
if x == "D":
print ("found letter", x)
But in my scenario I do not know what characters will be present in my 7 character length string so I can't search for "D" obviously.
So I have ideas I need to read the file, check for a string of length 7 (I am unsure how to handle stuff in the file like this:
line 1: My path = "7characters" (so basically finding even substrings that would qualify of 7 characters which contain uppercase and numeric
I dont know, this is simple, but yet I don't think i am understanding the basic logic behind it.