Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FlipFlop operator in Python
class FlipFlop: # the objects should be used by single thread def __init__(self, entry, exit): self.conditions = entry, exit self.state = False def __call__(self, value): if self.conditions[self.state](value): self.state = not self.state return self.state #__bool__ = None # to don't forget about calling the object if __name__ == '__main__': condition = FlipFlop('<'.__eq__, '>'.__eq__) while True: try: line = input() except EOFError: break else: print(''.join(c.upper() if condition(c) else c for c in line))
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Ваня и забор
kenken1
Linear search
Celcius to Fahrenheit
max min diff list
Reverse linked-list in-place
Depth First Search - Find if path exists
floating point limitations
количество 1 и 0 в последовательности чисел до n
on_off
Please log in to post a comment.