while-loop problem for acess a list element

I want to append each element of [1,2] to [[1], [2], [3]] and as a consequence, the final array that I want is [[1,1], [1,2], [2,1], [2,2], [3,1], [3,2]] But my code has a mistake I couldn’t recognize …

Python : Amount input with While

Beginner here. I’m trying to build a loop where the chekout displays a total amount that has to be over 0$. For example, if I start with 450$ the code works. But if I start with say -12 it will ask me …

Pygame window isn’t updating

I’m writing a small python game just to learn how to use python better. I wanted to try to start using multiple scripts, as keeping all of the code in one script can get a little crowded. I made a …

Can not force stop python script using ctrl + C

Normally to force stop python script that are running, we normal just press Ctrl + C (in Interactive console). In this case, it does not stop, when I press Ctrl + C. Here is my code for this situation:…

Python Walrus Operator in While Loops

I’m trying to understand the walrus assignment operator. Classic while loop breaks when condition is reassigned to False within the loop. x = True while x: print(‘hello’) x = False Why doesn’…

repeating a program using while loop failed

I coded a program that is meant to repeat itself over and over until the to_continue loop is broken by the input “N”. However, it didn’t seem to work. phone_or_tablet=int(input(“Phone …

Compare each element of a list in existing order with elements of a second list in order as long as items in lists are equal

Compare each element of a list in existing order with elements of a second list in existing order as long as items in lists are equal. Stop if they’re not equal and give me as result the index and …

Should I be using an if statement or a loop?

It’s me, your friendly Python noob! I’m working on this program and I’m trying to figure out how to get the program to stop if the number exceeds a certain threshold OR if the user enters anything …

Python while loop not working as intended

I don’t know how to get over this problem with while loop. So basically I want to return the number of zeros at the end of a number’s factorial. import math def zeros(n): total_zero = 0 n = …

Iteration numbers with True False condition

Please HELP!! I have a list: a = [‘False’, ‘False’, ‘True’, ‘True’, ‘True’, ‘False’, ‘False’, ‘True’, ‘True’] I want to generate iteration number if it’s False the number continues and if it’s True …