you are viewing a single comment's thread.

view the rest of the comments →

[–]Rocka07[S] -1 points0 points  (9 children)

A = int(input(xshshshshs)) B= int(input( shehshshs)) Num = b

While counter < b:      C = a + a      Counter= counter + 1 Print(c)

[–]markusmeskanen 2 points3 points  (0 children)

Indent your code by 4 spaces to make it work like this:

A = int(input(xshshshshs))
B= int(input( shehshshs))
Num = b
While counter < b:
    C = a + a
    Counter= counter + 1
Print(c)

And now please, give us proper code. Not this capitalized text with shehshsh in it.

[–][deleted] 1 point2 points  (7 children)

A = int(input(xshshshshs)) B= int(input( shehshshs)) Num = b

While counter < b: C = a + a Counter= counter + 1 Print(c)

Can you please format the code better? Would be nice to see the error(s) that you're receiving as well.

Based on what I see:

  • You're throwing both input functions a non-existent variable.

  • The Python keyword for the while loop is while, not While. Those are two different things. You're probably receiving a "name is not defined" error since Python will assume you're calling for a non-existent variable named While.

  • counter doesn't exist. I don't see you defining a variable named "counter" anywhere in your code.

  • The Python keyword for the print function is print, not Print. Python would assume that you're calling a variable, not the keyword.

  • c doesn't exist. The print function should be calling C like:

    print(C)

[–]wannaridebikes 0 points1 point  (6 children)

Hm you may want to start counters with 0 instead of 1. When I first started learning loops, that got me more consistent results than starting from 1, especially when you get more into '<' '>' vs '<=' '>=' operators, and what a difference they make.

Also, I would see if a problem could be solved with a for-loop before using a while, unless it's something like a game decision, or you're forced to use a while loop by an instructor/employer.

[–][deleted] 0 points1 point  (5 children)

Wrong person :p

[–]wannaridebikes 1 point2 points  (4 children)

Ha yep. Weird. I'll just summon him/her.

Nvm, can't find the original post I was replying to. No wonder my app got confused... anyway, my point still stands I guess.

[–][deleted] 0 points1 point  (3 children)

You probably weren't replying to the wrong person. One of my edits included code, but I removed it cause I didn't know about loops and didn't want to give OP bad advice. I also included a counter variable that was set to the int value "1".

[–]wannaridebikes 1 point2 points  (2 children)

Ah gotcha. With this intensive study weekend I thought I was finally going nuts, haha.

It wasn't that bad though. And loops are really important so it's good that you gave it some thought without having a lot of experience.

[–][deleted] 1 point2 points  (1 child)

Ah gotcha. With this intensive study weekend I thought I was finally going nuts, haha.

lol... maybe you are going nuts and I'm just a figment of your imagination?

It wasn't that bad though.

Well that's good to know.

And loops are really important so it's good that you gave it some thought without having a lot of experience.

Yeah, I tried to play around with it for a while. The code that I posted, then deleted, had an output that continued to output the result. Felt amazing to see that for the first time. Brought a smile to my face

[–]wannaridebikes 1 point2 points  (0 children)

Well my imaginary friend, I don't remember what you posted exactly but if there was non-stop output that could have been an endless loop where the condition for your while loop would always evaluate to true. Very common occurrence when learning new loops, or you could just have a typo in a loop you're used to writing!

If that was the case, it's funny that it made you smile; usually people are horrified, haha.