Hi I am new to the forums and to Python!
I am having trouble displaying a text menu in the following format
1: Name
2: Name
3: Name
It displays it correctly but then it gives an error message: Below is the code with output and error message.
#CreateMenu.py
#Create a standard text menu
#Create class menu
class TextMenu:
def __init__(self, listMenu):
self.listMenu = listMenu
#print menu
def __str__(self):
self.i = 1
self.index = len(self.listMenu)
while self.i < self.index:
print str(self.i) + ': ' + self.listMenu[self.i]
self.i = self.i + 1
#Test menu
list =
Menu = TextMenu(list)
print Menu
# Here is the output - with the error message
Evaluating CreateMenu.py
1: one
2: two
3: three
4: four
TypeError: __str__ returned non-string (type NoneType)
Any help would be appreciated.
PS: My code was indented - the indentation was removed when I posted