Skip to content

Instantly share code, notes, and snippets.

import random
m = [5,2,6,9,5,2,65,6,5,5,5,5,5]
k = [x for x in range(0,random.randint(0,90))] # using random.randint() to generate a random list
common_list = [x for x in m for y in k if x == y] # using list comprehension to seek common elements from the list
new_set = set(k) # using the set constructor to convert the list into the set so there will be no duplicatopn of the element
final_list = list(new_set) # converting back into list
import random
import time
def guess_game():
'''Life Is NOthing But A Game'''
user_guess = input('Bro enter a random number / OR PRess q to quti : ')
computer = random.randint(0,9)
while user_guess != 'q':
try:
user_guess = int(user_guess)
except:
p1 = input('Emter rock/paper/siccor OR press q to quit : ')
p2 = input('Emter rock/paper/siccor OR press q to quit : ')
while p1 != 'q' and p2 != 'q':
if p1 == 'rock' and p2 == 'siccor':
print('Player 1 has won ')
elif p1 == 'paper' and p2 == 'rock':
print('player has won : ')
elif p1 == 'siccor' and p2 == 'paper':
print('player 1 has won')