I want to print String and number both from list randomly
Question:
import random
s=[1,2,3]
b={'AM','PM'}
c=random.shuffle(s,b)
print(c)
I want ot print both from random in python.
I want output like this: 1AM OR 3 PM`
Answers:
To my understanding what you are trying to achieve is a random time using the list and the set.
To do so you’ll have to choose one random element from list followed by one from the set.
Here is it the code which works, with minimal number of changes from your code.
import random
s=[1,2,3]
b={'AM','PM'}
c=str(random.choice(s))+random.choice(tuple(b))
print(c)
Hope this helps✌️
import random
s=[1,2,3]
b={'AM','PM'}
c=random.shuffle(s,b)
print(c)
I want ot print both from random in python.
I want output like this: 1AM OR 3 PM`
To my understanding what you are trying to achieve is a random time using the list and the set.
To do so you’ll have to choose one random element from list followed by one from the set.
Here is it the code which works, with minimal number of changes from your code.
import random
s=[1,2,3]
b={'AM','PM'}
c=str(random.choice(s))+random.choice(tuple(b))
print(c)
Hope this helps✌️