ERROR: Internal Python error in the inspect module
Question:
I was assigned in a edx python course to create a program that print out the longest substring that is in alphabetical order from a given string. I have written my code, but when i ran it I got “ERROR: Internal Python error in the inspect module.”. I don’t understand why. If someone could help me figure it out it would be great. This is the code:
s = 'azcbobobegghakl'
start=0
temp=0
while start<len(s):
initial=start
while True:
if ord(s[start])<=ord(s[start+1]):
start+=1
else:
start+=1
if len(s[initial:start])>temp:
sub=s[initial:start]
temp=len(sub)
break
print sub
and this is the full error:
Traceback (most recent call last):
File "C:UsersYoavAppDataLocalEnthoughtCanopyAppappdatacanopy-1.5.4.3105.win-x86_64libsite-packagesIPythoncoreultratb.py", line 776, in structured_traceback
records = _fixed_getinnerframes(etb, context, tb_offset)
File "C:UsersYoavAppDataLocalEnthoughtCanopyAppappdatacanopy-1.5.4.3105.win-x86_64libsite-packagesIPythoncoreultratb.py", line 230, in wrapped
return f(*args, **kwargs)
File "C:UsersYoavAppDataLocalEnthoughtCanopyAppappdatacanopy-1.5.4.3105.win-x86_64libsite-packagesIPythoncoreultratb.py", line 267, in _fixed_getinnerframes
if rname == '<ipython console>' or rname.endswith('<string>'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 3: ordinal not in range(128)
ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.
Unfortunately, your original traceback can not be constructed.
Thanks!
Answers:
Looks like the code mostly works, however when you call break, it only breaks out of the else block, and continues to run the while, with a value for start that is greater than the max index for s.
Try putting this code in a function, and using a return when you find the correct substring
Good luck!
def sub_finder(s):
start=0
temp=0
while start<len(s):
initial=start
while True:
if (start < len(s) - 1):
if ord(s[start])<=ord(s[start+1]):
start+=1
else:
start+=1
if len(s[initial:start])>temp:
sub=s[initial:start]
temp=len(sub)
break
else:
start+=1
if len(s[initial:start])>temp:
sub=s[initial:start]
temp=len(sub)
return sub
test = 'abcdaabcdefgaaaaaaaaaaaaaaaaaaaaaaaaaaaabbcdefg'
print sub_finder(test)
whoops, try this on for size.
WARNING:tensorflow:Output dense_5 missing from loss dictionary. We assume this was done on purpose. The fit and evaluate APIs will not be expecting any data to be passed to dense_5.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
I was assigned in a edx python course to create a program that print out the longest substring that is in alphabetical order from a given string. I have written my code, but when i ran it I got “ERROR: Internal Python error in the inspect module.”. I don’t understand why. If someone could help me figure it out it would be great. This is the code:
s = 'azcbobobegghakl'
start=0
temp=0
while start<len(s):
initial=start
while True:
if ord(s[start])<=ord(s[start+1]):
start+=1
else:
start+=1
if len(s[initial:start])>temp:
sub=s[initial:start]
temp=len(sub)
break
print sub
and this is the full error:
Traceback (most recent call last):
File "C:UsersYoavAppDataLocalEnthoughtCanopyAppappdatacanopy-1.5.4.3105.win-x86_64libsite-packagesIPythoncoreultratb.py", line 776, in structured_traceback
records = _fixed_getinnerframes(etb, context, tb_offset)
File "C:UsersYoavAppDataLocalEnthoughtCanopyAppappdatacanopy-1.5.4.3105.win-x86_64libsite-packagesIPythoncoreultratb.py", line 230, in wrapped
return f(*args, **kwargs)
File "C:UsersYoavAppDataLocalEnthoughtCanopyAppappdatacanopy-1.5.4.3105.win-x86_64libsite-packagesIPythoncoreultratb.py", line 267, in _fixed_getinnerframes
if rname == '<ipython console>' or rname.endswith('<string>'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 3: ordinal not in range(128)
ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.
Unfortunately, your original traceback can not be constructed.
Thanks!
Looks like the code mostly works, however when you call break, it only breaks out of the else block, and continues to run the while, with a value for start that is greater than the max index for s.
Try putting this code in a function, and using a return when you find the correct substring
Good luck!
def sub_finder(s):
start=0
temp=0
while start<len(s):
initial=start
while True:
if (start < len(s) - 1):
if ord(s[start])<=ord(s[start+1]):
start+=1
else:
start+=1
if len(s[initial:start])>temp:
sub=s[initial:start]
temp=len(sub)
break
else:
start+=1
if len(s[initial:start])>temp:
sub=s[initial:start]
temp=len(sub)
return sub
test = 'abcdaabcdefgaaaaaaaaaaaaaaaaaaaaaaaaaaaabbcdefg'
print sub_finder(test)
whoops, try this on for size.
WARNING:tensorflow:Output dense_5 missing from loss dictionary. We assume this was done on purpose. The fit and evaluate APIs will not be expecting any data to be passed to dense_5.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.