I can not figure out what mistake I've done with my code. The error indicates that the class can not be imported. But I am not getting into it.
Please help me with this.
My code:
The error shown is:
Please help.
Please help me with this.
My code:
Code:
######## userClass.py ##################
from classTriangle import classTriangle
class userClass():
def __init__(self):
self.getList = []
self.maxList = 3
def getUserList(self):
print("*** getting user input ***")
while len(self.getList) < self.maxList:
item = input("enter numbers: ")
self.getList.append(item)
return self.getList
def showUserList(self,passedList):
print("*** showing user input ***")
print (passedList)
print ("length of the list: ", len(passedList))
if __name__=='__main__':
ui = userClass()
mk = classTriangle()
displayList = ui.getUserList()
ui.showUserList(displayList)
print(mk.createTriangle())
########classTriangle.py############
from userClass import userClass
class classTriangle():
def __init__(self):
self.makeList = []
self.bridgeList = []
self.finalList = []
def createTriangle(self):
UI = userClass()
self.makeList = UI.getUserList()
while len(self.makeList)>1:
for i in range(len(self.makeList)):
j = i + (i+1)
self.bridgeList.append(j)
del self.makeList[:]
self.makeList.extend(self.bridgeList)
self.finalList.extend(self.bridgeList)
del self.bridgeList[:]
return self.finalList
Code:
Traceback (most recent call last):
File "/home/gharry/workspace/myProject/makeTraingle/classTriangle.py", line 6, in <module>
from userClass import userClass
File "/home/gharry/workspace/myProject/makeTraingle/userClass.py", line 6, in <module>
from classTriangle import classTriangle
File "/home/gharry/workspace/myProject/makeTraingle/classTriangle.py", line 6, in <module>
from userClass import userClass
ImportError: cannot import name 'userClass'
Comment