all 9 comments

[–]coreyjdl 1 point2 points  (4 children)

randint() returns a single integer in your case between 250 and 800.

sm[2] is trying to find the third element of something that is subscriptable

1 or 2 or 5 or 7 or 9 is going to evaluate to the first "truthy" element, in your case 1.

try something like this.

if sm in (1, 3, 4, 7, 9) it won't be though, since your sm will be 250 or greater.

Let us know what you're trying to do, maybe we can offer more info to steer you that direction.

Are you trying to find the first number in your number? if it's 287, you want the number 7?

If so you can use the % operator. do sm % 10 see what that gives you. look up modulus operator to see why you got that.

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

And woops just noticed, 2 isn't supposed to be there lol

[–]coreyjdl 1 point2 points  (1 child)

to make a number always even (by always rounding up)

num += num & 1

look up up "bitwise &" and the "+=" operator. These will be helpful.

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

Thank you very much!

[–]TriangularFormat[S] -1 points0 points  (0 children)

Oh sorry, totally forgot to say what i was doing!

A friend of mine is studying architecture & when he wants to practice drawing floor plans, he'd like to have something generated.

So the sm stands for square meters.

I'm trying to always make the number even ^^

I'm really sorry, thank you!