Reputation: 313
I am trying to write a function that takes inputs and converts them into random types.
e.g. input as integer and output would be random of int,str,bool or float
Upvotes: 0
Views: 135
Reputation: 2098
I don't know if this is what you're looking for... as I don't see the point of doing that but I guess that this works:
import random
def random_type(x):
fun = random.choice([int, float, str, bool])
return fun(x)
Upvotes: 1