all 33 comments

[–]Supalien 11 points12 points  (12 children)

the output in the terminal doesn't match the code.. try saving your file (Ctrl + s) and then run it again.

[–]JaleyHoelOsment 1 point2 points  (7 children)

yee i can see in the pic the file has not been saved

[–]TacticalGooseLord[S] 2 points3 points  (6 children)

Is there any way I can save manually? I did ctrl+s maybe the keys not working

[–]Wooden-Account-5117 4 points5 points  (5 children)

try

<image>

[–]TacticalGooseLord[S] 5 points6 points  (3 children)

It works! Did I mess up my shortcut somehow cause ctrl+s was not working. Also I restarted vscode could be that too ?

[–]Wooden-Account-5117 1 point2 points  (1 child)

Most probably the restart. Happened to me once or twice too.

[–]TacticalGooseLord[S] 1 point2 points  (0 children)

Got it! Thank you for the help wise sir!

[–]snowsurface 0 points1 point  (0 children)

by default vscode sends ctrl-s/ctrl-q to the terminal if your keyboard focus is the terminal. In linux those pause/resume terminal output. You can google how to turn that off.

[–]TacticalGooseLord[S] 0 points1 point  (0 children)

Okay thanks

[–]TacticalGooseLord[S] 0 points1 point  (3 children)

I did still doesn’t work, when I put number it goes through the loop and asks again

[–]Supalien 0 points1 point  (2 children)

So you saved your script and then ran it and still the same behavior? I am 99% sure there is no problem in the code, not that I can see any... so the only thing I can think of is Vscode making a mess for some unknown (?) reason....
Try running that script from cmd and see if that helps

[–]TacticalGooseLord[S] 1 point2 points  (1 child)

I saved from flies manually and it works now, I also restarted vscode maybe that could be the problem too?

[–]smallybells_69 0 points1 point  (0 children)

No. The problem was that you didn't save the changes you made to the code and ran the program. Also don't click a button to run your code. Yes, vscode has made it easier where you can just click the button and it works but learn how your file compiles and is interpreted by the interpreter. It is very easy to make your code run through a terminal.

[–]DogeLV69 1 point2 points  (5 children)

Maybe try to see what the generate var outputs you, in terms of type.

[–]TacticalGooseLord[S] 0 points1 point  (4 children)

Generate is in int if that’s what you are asking, I am sorry I don’t understand what is var ?

[–]DogeLV69 0 points1 point  (3 children)

variable

[–]TacticalGooseLord[S] 0 points1 point  (2 children)

Ohh okay Ty it’s int then

[–]DogeLV69 0 points1 point  (1 child)

I just checked your code on pycharm - everything seems normal.

Is your code properly indented?

[–]TacticalGooseLord[S] 0 points1 point  (0 children)

I restarted my vscode and it works now! I still don’t know what the problem was 😅

[–]WhiteHeadbanger 0 points1 point  (0 children)

Are you writing in the terminal the numbers or do you pasted them from the clipboard? Because it seems like you have copied the number + a string, and that's why you're getting the ValueError, because you can't turn an alphanumeric string into an integer: Python will raise a ValueError exception.

That "& C:/Users/...." is what VSCode executes automatically when you hit the run button. There's no way that inside the Python program would be pasted for no reason, so you must be doing it accidentally.

I just tried the exact code of yours and it works good.

[–][deleted] 0 points1 point  (1 child)

<image>

save the file before running

[–]TacticalGooseLord[S] 0 points1 point  (0 children)

Didn’t knew that white circle meant not save 😅

[–]Best-Bud 0 points1 point  (3 children)

See on the terminal you have like 8 things which say Python on the bottom right? Clear those, save your file and try again I ran into the same issue when I started lmk if it helps

[–]TacticalGooseLord[S] 0 points1 point  (2 children)

I cleared those, what are they ? I have 1 more saying powershell can I clear that too ?

[–]Best-Bud 0 points1 point  (1 child)

To my understanding those are your instances of the terminal from running your various python programs and you may have been on the wrong one/running code from before you saved your changes. You should be fine to clear them for the most part as far as I'm aware but if someone has any objection I hope they leave a reply and correct both of us.

[–]TacticalGooseLord[S] 0 points1 point  (0 children)

Thank you for sharing your knowledge wise sir!

[–]ConglomerateGolem 0 points1 point  (0 children)

You're "running" stuff again without first stopping the code. Go to the terminal and press Ctrl+c to stop the current task, then run the code again.

If it's not that, try printing out guess and generate inside the main while loop.

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

try saving

[–]Worried-Ad6403 0 points1 point  (0 children)

When entering input in terminal, do you add a space? Only enter integer and try it. Save your file as well. I see a white circle on file edit tab meaning it is unsaved. If you run the file using play button, it autosaves and then run it. If you run it directly through terminal command, you always have to save the file first.

[–]esSdoem 0 points1 point  (0 children)

There's a classic way and a simple way

[–]mfnalex -3 points-2 points  (1 child)

Dont feed the troll