Python is a "strongly typed" language. It doesn't turn text (a string) into a number (an int) automatically. It doesn't turn the number randint(0, 1)
into a boolean either. But you can tell it to make conversions such as str(right_write)
or int(wire_choice)
.
Converting a number to a boolean is a little different. Python objects have a method nonzero
which Python calls when needed, implicitly, to determine whether the object is to be considered false or true. And booleans are subclass of int
, so they have integer values. You still have the option to convert explicitly as bool(randint(0, 1))
or by using an expression like randint(0, 1) == 0
.
I haven't explained exactly how to code your solution because I feel certain that you can take it from there and because you can make your own choice of how you prefer to express your code.
P.S. I'd like to link to more information about the special case of the boolean value of non-boolean objects. In particular, Python specifically permits us to test the truth value of non-booleans. And we are advised to do so, or at least, Google's guide recommends testing the truth value of non-booleans.