Reputation: 1
Basically I have a variable equal to a number and want to find the number in the position represented by the variable. This is what I
numbertocheck =1
loopcriteria = 1
while loopcriteria == 1:
if numbertocheck in ticketnumber:
entryhour.append[numbertocheck] = currenttime.hour
entryminute.append[numbertocheck] = currenttime.minute
print("Thank you. Your ticket number is", numbertocheck)
print("There are now", available_spaces, "spaces available.")
loopcriteria = 2
I get this error (in pyCharm):
Traceback (most recent call last): File "/Users/user1/Library/Preferences/PyCharmCE2017.3/scratches/scratch_2.py", line 32, in entryhour.append[numbertocheck] = currenttime.hour TypeError: 'builtin_function_or_method' object does not support item assignment
How do I do what I'm trying to do?
Upvotes: 0
Views: 24
Reputation: 1914
Though you haven't provided the complete code, I think you only have problem with using append. You cannot use []
just after an append
. To insert into a particular position, you need insert
Putting the relevant lines you need to replace below...
entryhour.insert(numbertocheck,currenttime.hour)
entryminute.insert(numbertocheck,currenttime.minute)
# available_spaces-=1 # guessing you need this too here?
P.S. your loop doesn't seem to make sense, I hope you debug it yourself if it doesn't work the way you want.
Upvotes: 0