Convert Token to Flag
Python
Medium
2 views
Problem Description
Input is a single token t is provided. If t is True output 1, if False output 0, if NONE output NULL. Otherwise output t unchanged.
Input Format
One token t.
Output Format
One token output.
Constraints
Token has no spaces.
Official Solution
import sys
t=sys.stdin.read().strip()
if not t: sys.exit(0)
if t=='True':
sys.stdout.write('1')
elif t=='False':
sys.stdout.write('0')
elif t=='NONE':
sys.stdout.write('NULL')
else:
sys.stdout.write(t)
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!