+ 1

Could you help me to improve this code?

I dont know why when i write 69 it still takes me to the end of the queue. The goal is to when i write 69 i would be first. queue = [1,2] (place:=int(input())) vip = 0 if place == 69: queue.insert[vip, place] print(len(queue)) else: queue.append(place) print(len(queue))

22nd Dec 2021, 1:24 PM
Dawid Kępka
1 Resposta
+ 3
You call insert() method using square brackets where you should be using parentheses. In either case, whether <place> equals to 69 or not, you print the list length. That's why it appears "took you to the end". But actually it's only printing number of items in the list. In the case where <place> equals to 69, you can instead use index() method, and just add 1 if you want 1-base value print(queue.index(place)) P.S. Please add Python in your thread's tags for language context clarity☝
22nd Dec 2021, 1:43 PM
Ipang