Hello thx for wasting ur time pressing this and bothering to help :) .
Basically I'm making a program that can do certain well things
like option 1 option 2 option 3 etc
so, so far option 1 only works but 2 doesn't (I didn't make 3 or 4)
i would love if u guys can spare the time to help
ty
Solution
I guess the way you are doing it will work, but the way I'm showing you is easier, and better, do it like this:
a = 1
a = int(a)
b = 2
b = int(b)
c = 3
c = int(c)
d = 4
d = int(d)
if a == 1:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
# and so on, write your code
so instead of <=
or something, do ==
and turn the variables to ints, so this way is easier
That should work
You can't compare strings to numbers. So that means 1 >= "1"
won't give you very defined behavior.
Consider making them an int:
a = int(input())
if a >= 1:
...
@Coder100
oh okay thx :)
I'm not 100% sure but since your variables have > or < sign it may get confused between which variable to pick? So I suggest just doing a = "1" b = "2". Idk hope that helped
@Shell101 okay ill try that thx
I recommend creating a map of strings (options) to functions/lambdas (things that the option does).
If the option is not a map key, then show an error message.
If the key is present, get the map's value and call the function/lambda.
@MaryamNegeda Seeing as you had accepted my answer, how well did it work out?
Example implementation:
@xxpertHacker
lol yeah tysm for that