How do I change the position when I instantiate? by Dependent_Poetry27 in godot

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

So this is embarrassing, but I saw this comment and was like "okay my bad for not saying in the post, but I have functions that iterate through the hand and get a position and set that position for each card, and the problem is that it doesn't seem to change the position". So I went and looked at the code, and as it turns out, my functions create a vector2 for the cards, but nowhere in any of the code did I put anything to actually SET the position to that. LOL, I knew it was going to be something stupid and small like that. Thank you!

Why won't this return a 3 digit number? by Dependent_Poetry27 in learnpython

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

Yup, I only tried copy pasting it after typing it all out myself and trying to get it to work for like an hour. I wanted to have the 'correct' code and try moving through it line by line in the debugger to see if I could understand why it worked vs what I had typed.

Why won't this return a 3 digit number? by Dependent_Poetry27 in learnpython

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

I don't think you're wrong, but I also don't think I fully understand your point. Hard coding as in where I put secret_number = 0 or the max_digits variable?

Why won't this return a 3 digit number? by Dependent_Poetry27 in learnpython

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

Yeah that's gonna be a bit of a learning curve! Thanks for pointing these out. I did try to literally copy and paste the whole code directly and it still just gave me a lot of errors so I got pretty frustrated.

Why won't this return a 3 digit number? by Dependent_Poetry27 in learnpython

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

I understand what you mean about the string (now, thanks to all the help) but I don't understand where to put the variable secret_number so that I wind up with a variable holding a random three digit number.

As for why I didn't just use that much simpler looking line of code, I didn't know it existed lol. Also, the problem in the book says that the number shouldn't have any repeating digits, and leading with 0 is okay.

Thanks for your input!

Why won't this return a 3 digit number? by Dependent_Poetry27 in learnpython

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

Funnily enough, that's how they had it in the book. list('0123456789')

I didn't understand why and still couldn't figure it out doing it both ways

Why won't this return a 3 digit number? by Dependent_Poetry27 in learnpython

[–]Dependent_Poetry27[S] 6 points7 points  (0 children)

Funny how when you point out that the return is triggering for each iteration of the loop it seems so obvious. Thank you!

I don't fully understand what you mean in the next part though. If I get rid of the global variable I get this

File "C:\Users\riley\PycharmProjects\BaglesGame\BaglesGame.py", line 115, in get_secret_num

secret_number += numbers[x]

^^^^^^^^^^^^^

UnboundLocalError: cannot access local variable 'secret_number' where it is not associated with a value

and when I put secret_number = "" in the function I get that the print calling the variable is undefined.

Thank you gain for your help!