+ 2

I can't understand while loop in python

It's a bit confusing

15th Jul 2021, 4:32 PM
Roselyne Anjie
Roselyne Anjie - avatar
8 odpowiedzi
+ 1
Roselyne Anjie I also encountered that yesterday and I posted it on my feed for help on how to solve it and nobody answered so I just skipped it. When I get better I will go back to it, I think you should do the same
17th Jul 2021, 12:43 PM
Amuwa Timothy
Amuwa Timothy - avatar
+ 4
Think about it as a sentence. Say i wanted to pick up cans all day, unless there was a lightning storm. while(there's no storm) pick up cans Its just a way to do something over and over until a specific condition is met to stop it
15th Jul 2021, 4:40 PM
Slick
Slick - avatar
+ 3
You said while loop. While loop is for an undetermined amount of cycles. Use a for loop, because it gives you the number of inputs
15th Jul 2021, 6:21 PM
Slick
Slick - avatar
0
what exactly you didn't understand?
15th Jul 2021, 4:40 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
0
Give an example than its better to explane that
15th Jul 2021, 6:17 PM
Angela
Angela - avatar
0
Here is it , it's a problem
15th Jul 2021, 6:18 PM
Roselyne Anjie
Roselyne Anjie - avatar
0
You are making a game! The player tries to shoot an object and can hit or miss it. The player starts with 100 points, with a hit adding 10 points to the player’s score, and a miss deducting 20 points. Your program needs to take 4 action results as input ("hit" or "miss"), calculate and output the player’s remaining points. Sample Input hit hit miss hit Sample Output 110 Explanation: 3 hits add 30 points, one miss deducts 20, making the total points equal to 110.
15th Jul 2021, 6:19 PM
Roselyne Anjie
Roselyne Anjie - avatar
0
An example is a = 0 while a < 3: print(a) a = a + 1 This prints incremented value of a by 1, 3 times
16th Jul 2021, 8:53 AM
SparkyThe Plqayer