Reputation: 154
I know this is probably quite a simple problem but I am having an issue with the formatting of my function. I am getting a lot of 'unexpected indent' and also 'unexpected token'. I keep trying to format the function correctly but I have no idea why these errors keep on appearing. Here is my function:
def stringCheck(stringForCheck, letterOrNumber):
valid = True
x = 0
a = int(ord(stringForCheck)
length = len(stringForCheck)
if LetterOrNumber == 'Letter':
lowerBoundary = 65
upperBoundary = 90
elif LetterOrNumber == 'Number':
lowerBoundary = 48
upperBoundary = 57
while valid == True and x < length:
if a < lowerBoundary or a > upperBoundary:
valid = False
else:
valid = True
x = x + 1
stringCheck = valid
stringCheck('2','Number')
Upvotes: 0
Views: 107
Reputation: 692
a = int(ord(stringForCheck)
if LetterOrNumber == 'Letter':
to your while
loop the lines have one indentation level too much.After fixing the code it should look something like this:
def stringCheck(stringForCheck, letterOrNumber):
valid = True
x = 0
a = int(ord(stringForCheck))
length = len(stringForCheck)
if LetterOrNumber == 'Letter':
lowerBoundary = 65
upperBoundary = 90
elif LetterOrNumber == 'Number':
lowerBoundary = 48
upperBoundary = 57
while valid is True and x < length:
if a < lowerBoundary or a > upperBoundary:
valid = False
else:
valid = True
x = x + 1
stringCheck = valid
stringCheck('2', 'Number')
Upvotes: 3
Reputation: 1
Try adding a close bracket after the line
a = int(ord(stringForCheck))
Upvotes: 0