File size: 207 Bytes
4d8662a
 
 
 
 
 
 
1
2
3
4
5
6
7
def str2bool(string):
  str2val = {"True": True, "False": False}
  if string in str2val:
    return str2val[string]
  else:
    raise ValueError(
      f"Expected one of {set(str2val.keys())}, got {string}")