Hi thanks for the replies, i really appreciate it.
this what i initially came up with using some logic and trying solve it like a math problem while wording using english but not the computer terminology and thats what i came up with and know its wrong even though i have the solution for it but i would like to go through my code above and get it correct and understand it.
thanks.
Also i am doing list on the side aswell trying get ahead before my next class
This is the question:
Create a simple list to hold the items 1,2,3,4, creating the list “from the front” as in Slide 48.[Notice how the list is only complete when you have finished.]Use the code from Slide 50 to print out your list. (You may want to write this as a function.)
And just wanted did i assemble the code properly that i got from the slide 48 and 50(read question)
Quote:i= 1
while i<=5:
print("beer")
else i=6
print("sixpack")
else i=10
print("beer")
this what i initially came up with using some logic and trying solve it like a math problem while wording using english but not the computer terminology and thats what i came up with and know its wrong even though i have the solution for it but i would like to go through my code above and get it correct and understand it.
thanks.
Also i am doing list on the side aswell trying get ahead before my next class
This is the question:
Create a simple list to hold the items 1,2,3,4, creating the list “from the front” as in Slide 48.[Notice how the list is only complete when you have finished.]Use the code from Slide 50 to print out your list. (You may want to write this as a function.)
Quote:class Node:
pass
start = Node()
point = start
point.data = 1
point.next = Node()
point = point.next
point.data = 2
point.next = Node()
point = point.next
point.data = 3
point.next = Node()
point = point.next
point.data = 4
point.next = None
def func1():
point = start
print(point.data)
point = point.next
print(point.data)
point = point.next
print(point.data)
point = point.next
print(point.data)
point = point.next
print("point:", point)
func1()
And just wanted did i assemble the code properly that i got from the slide 48 and 50(read question)