#๐ need help with python while loops for my class, im new.
62 messages ยท Page 1 of 1 (latest)
@grave hinge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Could you supply a little more detail? Is there something specific you want explained?
how would i go about creating this code? i dont know much about python, i just want to make a infinite loop code that makes the numbers go like this
1
2
3
4
5
6.......
......100
and it does that over and over i think
my teacher gave me starting code, to start with but i dont know why its even there to be honest
counter = 0
total = 0
i tried doing this but i dont know how to make it 1-100 instead of 2 and i didnt use the counter = 0 or total = 0
atleast i think thats what its trying to get me to do
okay im getting somewhere i think
closer but not there
the top of the code was counter = 0 total = 0
You want print(counter), not printer counter
total wasnt used though
Okay
i need the numbers to add to each other i think
The last loop looks ok to me. Normally this would all be just one thing:
count = 0
while count < 100:
counter = counter + 1
print(counter)
let me try that
Good
Now
I Need to make the numbers add each other
how would i add all those numbers together for the total? @low marsh
Ah, I said count in the condition, not counter.
WHat do you want for the total? Every value of counter?
it gave me a error since count is not defined
Every value of the output added together
so 1+2+3+4+5+6........ continued until +100
So total starts as 0. Inside the loop, you want to add counter to total, just like you add 1 to counter.
Then after the loop you could print("total:", total) to see what you got.
... without the + 1
oo okay
You're just adding up the counter values.
It's just a way of thinking. You'll get there.
Oh, when you show the code could you copy/paste the text instead of a screenshot?
Yes sorry I will
I get this, a bit glaring.
Hey @grave hinge!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
Looks ok
Disord wants backticks ``` instead of apostrophes '''
print counter = 0
total = 0
while counter < 100:
counter = counter + 1
total = total + counter
print("total:", total)
total: 1
total: 3
total: 6
total: 10
total: 15
total: 21
total: 28
total: 36
total: 45
total: 55
total: 66
total: 78
total: 91
total: 105
total: 120
total: 136
total: 153
total: 171
total: 190
total: 210
total: 231
total: 253
total: 276
total: 300
total: 325
total: 351
total: 378
total: 406
total: 435
total: 465
total: 496
total: 528
total: 561
total: 595
total: 630
total: 666
total: 703
total: 741
total: 780
total: 820
total: 861
total: 903
total: 946
total: 990
total: 1035
total: 1081
total: 1128
total: 1176
total: 1225
total: 1275
total: 1326
total: 1378
total: 1431
total: 1485
total: 1540
total: 1596
total: 1653
total: 1711
total: 1770
total: 1830
total: 1891
total: 1953
total: 2016
total: 2080
total: 2145
total: 2211
total: 2278
total: 2346
total: 2415
total: 2485
total: 2556
total: 2628
total: 2701
total: 2775
total: 2850
total: 2926
total: 3003
total: 3081
total: 3160
total: 3240
total: 3321
total: 3403
total: 3486
total: 3570
total: 3655
total: 3741
total: 3828
total: 3916
total: 4005
total: 4095
total: 4186
total: 4278
total: 4371
total: 4465
total: 4560
total: 4656
total: 4753
total: 4851
total: 4950
total: 5050
ahhh
i see
Thank you
this is the right output i wanted
Any further questions?
not currently, will you be able to help later on today in like half an hour with different assignments?
Probably. You may need to ping me, depending what I'm doing.
i have more short python assignments for my class
should i dm you instead?
Just @cameron.simpson in the topic text. It's better to make a public thread for most things, unless we get into the weeds with something. If I'm around I'll probably answer, but otherwise other people can answer.
Alright thank you so much cameron!!
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.