Le newb here
Since in Python "switch" doesn't exist, what could i do to make this code less shit?
Thanks
>>58323716
stupid fuckin faggot learn to use google
https://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python
>>58323716
As dumb as it sounds, by not using Python.
Try Lua.
>>58323716
>make python less shit
Have you tried using a language that isn't full retard shit?
>>58323768
I remember there were some downsides of Lua.
>>58323716
dont use strings, use numbers
>>58323716
A list, retard. Switch statements (in C and Java) only deal with a single variable, so you'll need to insert a conditional for usChoice too. I would probably use an enum for this purpose anyway.
How about you just generate a random number between 1 and 3 (inclusive) and use that for the 3 possible outcomes of the game, instead of pretending that a users choice even matters and spending all those comparing strings
>>58324149
The only useful advice in this thread
You could try using a dictionary as a dispatch table.
>>58324886
>>58324149
it would confuse the logic of the game to just straight up use numbers. easier to use a container and just reference that by index programmatically, likeimport random
tools=("Rock","Paper","Scissor")
challenge=input("do the thing here: ").capitalize()
robot=random.choice(tools)
if challenge in tools:
if tools.index(challenge)==tools.index(robot):
print("tie; you chose {} and so did the damned robot".format(challenge))
elif tools.index(robot)==tools[tools.index(challenge)-1]:
print("you won! holy shit! the robot picked {} but you cunningly chose {}".format(robot, challenge))
else:
print("you lost, fucking loser. you picked {} and the robot picked {}".format(challenge,robot))
>using strings when the strings are already in an array
Nigga, you dumb.
>>58323716
holy shit nigger if you know a language like C/++ or Java and this is the best shit you could come up with in Pytoddler you should just give up now
but switch IS a bunch of elifs, anon
> array ["player wins", "pc wins", "tie"]
> get user input
> ignore it and generate a random array index and print it
Done
>>58325203
this actually. forget about my post >>58325024