One of the other requirements is to return something. Since your function returns nothing, None
is implicitly returned, and this causes the test scaffolding to fail. Perhaps you should return a list containing the return values of each invocation of illuminate()
.
NoneType object is not subscriptable
题
I am working on a seven-segment display project on Learnstreet. One of the required methods takes the input obtained from a text box which is labelled "inputString". Input String is then passed to the given method using text
which is a string. Further description of the method is as given below -
In this method we have got the text from that input string, and we need to extract each character from it, and if it is a number, pass it on to our illuminate function to display that number using a 7-segment display.
Here is my code for parsing the string and extracting digits from the number.
def get_digits(text):
num=int(text)
while num!=0:
print illuminate(num%10)
num/=10
This code throws an error :
Traceback (most recent call last): File "", line 1, in File "", line 27, in test File "", line 17, in test_get_digits TypeError: 'NoneType' object is not subscriptable.
Because I am new to python, I don't understand what is causing this.Please help
解决方案