Skip to content

Instantly share code, notes, and snippets.

@alyakhtar
Created May 31, 2017 22:23
Show Gist options
  • Save alyakhtar/190e04d9eb5ce39e70f3a4c65b3a8619 to your computer and use it in GitHub Desktop.
Save alyakhtar/190e04d9eb5ce39e70f3a4c65b3a8619 to your computer and use it in GitHub Desktop.
BOLLYWOOD GAME
import random
class Game(object):
def __init__(self):
self.current_movie = self.getMovie()
def getMovie(self):
movies = []
movie_name = ''
f = open('Movie_list.txt','r')
for i in f:
movies.append(i.strip('\n'))
r = random.randint(-1, len(movies)-1)
movies[r] = movies[r].upper()
for j in movies[r].upper():
if (ord(j) > 64 and ord(j) < 91) or ord(j) == 32 or (ord(j) > 47 and ord(j) < 58):
movie_name += j
return movies[r]
def updateString(self,oldString,character,actualName):
new_string = ''
for i in xrange(len(actualName)):
if actualName[i] == character:
new_string += character
else:
new_string += oldString[i]
return new_string
def playGame(self):
movie_uppercase = self.current_movie.upper()
movie_characters = {}
hint = 2
tries = len('bollywood')
vowels = [65,69,73,79,85]
guess_name = ''
for i in movie_uppercase:
if ord(i) not in vowels and ord(i) != 32:
if i in movie_characters:
movie_characters[i] += 1
else:
movie_characters[i] = 1
for i in movie_uppercase:
if ord(i) in vowels:
guess_name += i
elif ord(i) == 32:
guess_name += ' '
else:
guess_name += '_'
print 'GUESS THE MOVIE NAME\n'
while tries > 0:
print guess_name
if '_' not in guess_name:
break
print 'Chances Left: ',tries
print 'Hints left: ', hint
guess_character = raw_input('Guess a character or type "hint" for Hint: ').upper()
if guess_character == 'HINT':
if hint < 1:
print 'No Hints Left'
else:
lowest_count = 100
lowest_char = ''
for i in movie_characters:
if movie_characters[i] < lowest_count:
lowest_count = movie_characters[i]
lowest_char = i
guess_name = self.updateString(guess_name,lowest_char,movie_uppercase)
hint -= 1
del movie_characters[lowest_char]
else:
if guess_character in movie_characters:
guess_name = self.updateString(guess_name,guess_character,movie_uppercase)
del movie_characters[guess_character]
else:
print 'Wrong Guess'
tries -= 1
print '\n'
if tries == 0:
print 'SORRY, YOU LOST THE GAME!'
else:
print '\nCONRATUALATIONS, YOU GUESSED RIGHT!'
if __name__ == '__main__':
Game().playGame()
OK Jaanu
Haraamkhor
Coffee with D
Kaabil
Raees
Jolly LLB 2
Runningshaadi.com
The Ghazi Attack
Irada (2017 film)
Chauhar
Rangoon
Wedding Anniversary
Commando 2
Aa Gaya Hero
Jeena Isi Ka Naam Hai
Badrinath Ki Dulhania
Mona Darling
Phillauri
Machine
Anaarkali Of Aaraah
Bhanwarey
Hindi Medium
Naam Shabana
Jagga Jasoos
Sarkar 3
Begum Jaan
Kaalakaandi
Noor (film)
Baahubali 2
Meri Pyaari Bindu
Half Girlfriend
Sachin: A Billion Dreams
Toilet: Ek Prem Katha
Raabta
Munna Michael
Chef
Haseena: The Queen of Mumbai
Bareilly Ki Barfi
Mubarakan
Bhoomi (film)
Secret Superstar
The Ring
Reloaded
Baadshaho
Simran
Judwaa 2
Golmaal Again
2.0
Padmavati
Tiger Zinda Hai
Dutt
Wazir
Chalk n Duster
Rebellious Flower
Airlift
Jugni
Kyaa Kool Hain Hum 3
Saala Khadoos
Mastizaade
Sanam Teri Kasam
Ghayal Once Again
Fitoor
Sanam Re
Direct Ishq
Ishq Forever
LoveShhuda
Neerja
Dhara 302
Aligarh
Bollywood Diaries
Love Shagun
Tere Bin Laden Dead or Alive
Zubaan
Jai Gangaajal
Global Baba
Teraa Surroor
OK Mein Dhokhe
Kapoor & Sons
Rocky Handsome
Ki & Ka
Love Games
The Blueberry Hunt
Fan
Nil Battey Sannata
Laal Rang
Santa Banta Pvt Ltd
Baaghi
Shortcut Safari
One Night Stand
Traffic
1920 London
Azhar
Buddha in a Traffic Jam
Khel Toh Ab Shuru Hoga
Kaptaan
Sarbjit
Phobia
Veerappan
Fredrick
Waiting
Housefull 3
Do Lafzon Ki Kahani
Dhanak
Te3n
Udta Punjab
Luv U Alia
Raman Raghav 2.0
Junooniyat
7 Hours To Go
A Scandall
Rough Book
Shorgul
Dil Toh Deewana Hai
Sultan
Brahman Naman
Great Grand Masti
Madaari
Ishq Click
M Cream
Dishoom
Love Ke Funday
The Legend of Michael Mishra
Fever
Hai Apna Dil Toh Awara
Mohenjo Daro
Rustom
Happy Bhaag Jayegi
Waarrior Savitri
A Flying Jatt
Akira
Yea Toh Two Much Ho Gayaa
Island City
Baar Baar Dekho
Freaky Ali
Ek Kahani Julie Ki
Raaz Reboot
Pink
Parched
Banjo
Days of Tafree
Wah Taj
M.S. Dhoni: The Untold Story
Mirzya
MSG: The Warrior Lion Heart
Tutak Tutak Tutiya
Anna
Motu Patlu: King Of Kings
Beiimaan Love
Saat Uchakkey
Fuddu
Aakhir Kab Tak
Ek Tera Saath
Umrika
31st October
Shivaay
Ae Dil Hai Mushkil
Chaar Sahibzaade: Rise of Banda Singh Bahadur
Dongri Ka Raja
Ishq Junoon
Rock On 2
Tum Bin 2
Force 2
Dear Zindagi
Saansein
Moh Maya Money
Kahaani 2
Befikre
Wajah Tum Ho
Dangal
International Hero
Mumbai Can Dance Saala
Take It Easy
Sai Mahima
Tevar
Alone
Crazy Cukkad Family
Sharafat Gayi Tel Lene
Baby
Dolly Ki Doli
Chal Guru Ho Ja Shuru
Hawaizaada
Khamoshiyan: Silences Have Secrets
Rahasya
Jai Jawaan Jai Kisaan
Shamitabh
MSG: The Messenger
Roy
Badlapur
Qissa
Ab Tak Chhappan 2
Dum Laga Ke Haisha
Badmashiyaan
Coffee Bloom
Dirty Politics
Hey Bro
NH10
Dilliwali Zaalim Girlfriend
Hunterrr
Barkhaa
Detective Byomkesh Bakshy
Paisa Ho Paisa
Luckhnowi Ishq
Dharam Sankat Mein
Ek Paheli Leela
Court
Margarita with a Straw
Mr. X
NH-8 Road to Nidhivan
Ek Adbhut Dakshina Guru Dakshina
Ishq Ke Parindey
Kaagaz Ke Fools
Gabbar is Back
Sabki Bajegi Band
Kuch Kuch Locha Hai
Piku
Bombay Velvet
Main Hoon Rajinikanth
Tanu Weds Manu Returns
I Love Desi
Ishqedarriyaan
P Se PM Tak
Welcome 2 Karachi
Dil Dhadakne Do
Mere Genie Uncle 3D
Hamari Adhuri Kahani
ABCD 2
Miss Tanakpur Haazir Ho
Uvaa
Bezubaan Ishq
Guddu Rangeela
Second Hand Husband
Baahubali
I Love NY
Thoda Lutf Thoda Ishq
Bajrangi Bhaijaan
Aisa Yeh Jahaan
Masaan
Drishyam
Bangistan
All Is Well
Brothers
Gour Hari Dastaan
Manjhi: The Mountain Man
Rolling Dream
Kaun Kitney Pani Mein
Phantom
Welcome Back
Hero
Sorry Daddy
Katti Batti
Meeruthiya Gangster
MSG-2:The Messenger
Kis Kisko Pyaar Karoon
Calendar Girls
Bhaag Johnny
Time Out
Singh Is Bliing
Talvar
Jazbaa
Bumper Draw
Chinar Daastaan-E-Ishq
Pyaar Ka Punchnama 2
Wedding Pullav
Shaandaar
Titli
Main Aur Charles
Once Upon A Time In Bihar
Guddu Ki Gun
Love Exchange
Prithipal Singh... A Story
Four Pillars of Basement
Charlie Kay Chakkar Mein
Yaara Silly Silly
Ranbanka
Prem Ratan Dhan Payo
X
Angry Indian Goddesses
Tamasha
Hate Story 3
Kajarya
The Silent Heroes
Bajirao Mastani
Dilwale
Mr Joe B. Carvalho
Sholay 3D
Dedh Ishqiya
Yaariyan
Karle Pyaar Karle
Miss Lovely
Om-Dar-Ba-Dar
Paranthe Wali Gali
Strings Of Passion
Jai Ho
One by Two
Babloo Happy Hai
Hasee Toh Phasee
Heartless
Ya Rab
Gunday
Kaho Na Kaho
Darr @ the Mall
Dee Saturday Night
Gulabi Gang (film)
Highway
Karar — The Deal
Pyar Ka Live Show
The Dark Secrets Of Tonhi
Anuradha
Shaadi Ke Side Effects
Gulaab Gang
Queen
Total Siyapaa
Bewakoofiyaan
Neighbours: They Are Vampires
W
Ankhon Dekhi
Gang of Ghosts
Lakshmi
Ragini MMS 2
Dishkiyaoon
O Teri
Station: The Film
Youngistaan
Ebn-E-Batuta
Honour Killing
Jal
Main Tera Hero
Bhoothnath Returns
2 States
Dekh Tamasha Dekh
Lucky Kabootar
Kaanchi...
Revolver Rani
Samrat & Co.
Purani Jeans
Kya Dilli Kya Lahore
Angry Young Man
Kahin Hai Mera Pyar
Hawaa Hawaai
Khwaabb
Koyelaanchal
Manjunath
Mastram
Yeh Hai Bakrapur
The Xposé
Children of War
M3 - Midsummer Midnight Mumbai
Heropanti
Kochadaiiyaan
City Lights
Kuku Mathur Ki Jhand Ho Gayi
Filmistaan
Holiday
Fugly
Machhli Jal Ki Rani Hai
Humshakals
Ek Villain
Bobby Jasoos
Lekar Hum Deewana Dil
Humpty Sharma Ki Dulhania
Hate Story 2
Bazaar-E-Husn
Riyasat
Amit Sahni Ki List
Pizza
Kick
Entertainment
Singham Returns
Life is Beautiful!
Mad About Dance
Mardaani
Mumbhai Connection
Abhinay Chakra
Raja Natwarlal
Mary Kom
Creature
Finding Fanny
Daawat-E-Ishq
Khoobsurat
3 A.M.
Chaarfutiya Chhokare
Desi Kattey
Meinu Ek Ladki Chaahiye
Balwinder Singh Famous Ho Gaya
Bang Bang!
Haider
Jigariyaa
Ekkees Toppon Ki Salaami
Tamanchey
Mumbai 125 KM 3D
Sonali Cable
Happy New Year
Mumbai Can Dance Saala
Fireflies
Roar - Tigers of Sunderbans
Super Nani
Chaar Sahibzaade
Rang Rasiya
A Decent Arrangement
The Shaukeens
6 - 5 = 2
Kill Dil
Golu Aur Pappu
Happy Ending
Titoo MBA
Wah Taj
Hum Hai Teen Khurafaati
Ungli
Zed Plus
Zid
Action Jackson
Bhopal: A Prayer for Rain
Mumbai Delhi Mumbai
Sulemani Keeda
Take It Easy
Badlapur Boys
Life Mein Twist Hai
LUV...Phir Kabhie
Main Aur Mr. Riight
Objection My God
Room - The Mystery
PK
Lingaa
Ugly
Table No. 21
Dehraadun Diary
Meri Shadi Karao
Matru Ki Bijlee Ka Mandola
Pyaar Mein Aisa Hota Hai
Gangoobai
Inkaar
Mumbai Mirror
Bandook
Race 2
Akaash Vani
Main Krishna Hoon
David
Vishwaroop
Mai...
Listen... Amaya
Special 26
The Unsound
Jayantabhai Ki Luv Story
Murder 3
Kai Po Che!
Zilla Ghaziabad
I, Me, aur Main
Bloody Isshq
Saheb, Biwi Aur Gangster Returns
Saare Jahaan Se Mehnga
3G
Mere Dad Ki Maruti
Jolly LLB
20
29
Chashme Baddoor
Nautanki Saala
Commando-A One Man Army
19
Aashiqui 2
Shree
Shootout at Wadala
Bombay Talkies
Chhota Bheem And The Throne of Bali
Go Goa Gone
Gippi
Aurangzeb
I Don't Luv U
Beehad - The Ravines
Ishkq in Paris
Hum Hai Raahi CAR Ke
Zindagi 50-50
31
7
Fukrey
Ankur Arora Murder Case
Raanjhanaa
Enemmy
Romeo
28
Lootera
Policegiri
Bhaag Milkha Bhaag
Sixteen
B.A. Pass
Boyss Toh Boyss Hain
Ramaiya Vastavaiya
D Day
Ship of Theseus
Issaq
Bajatey Raho
Luv U Soniyo
Nasha
Rabba Main Kya Karoon
Chor Chor Super Chor
Calapor
Love in Bombay
9
15
23
30
Zanjeer
Shuddh Desi Romance
Siddharth
Grand Masti
John Day
Horror Story
Phata Poster Nikla Hero
The Lunchbox
Warning
Maazii
Prague
Super Model
War Chhod Na Yaar
Baat Ban Gayi
Pazhassi Raja
Ek Thee Sanam
Paapi - Ek Satya Katha
16
18
Wake Up India
Amdavad Junction
Dilli Gang
Mickey Virus
Ishk Actually
Sooper Se Ooper
1
8
Rajjo
Goliyon Ki Rasleela Ram-Leela
Gori Tere Pyaar Mein
Singh Saab The Great
29
6
Jackpot
What the Fish
Dhoom 3
6
Chaalis Chauraasi 4084
Ghost
Sadda Adda
26
Gali Gali Chor Hai
Staying Alive
Love You To Death
Ek Main Aur Ekk Tu
Valentine's Night
Ekk Deewana Tha
?: A question mark
Married 2 America
Jodi Breakers
Tere Naal Love Ho Gaya
London, Paris, New York
Paan Singh Tomar
Will You Marry Me?
Kahaani
Chaar Din Ki Chandni
Say Yes to Love
Akkad Bakkkad Bam Be Bo
Zindagi Tere Naam
23
Blood Money
Bumboo
5
Bittoo Boss
Chhodo Kal Ki Baatein
Ab Hoga Dharna Unlimited
Vicky Donor
Hate Story
Tezz
Life Ki Toh Lag Gayi (Film)
Jannat 2
Fatso!
The Forest
Love, Lies & Seetha
Dangerous Ishq
Ishaqzaade
Department
Chhota Bheem And The Curse Of Damyaan
Mr. Bhatti on Chutti
Arjun: The Warrior Prince
MLA
Rakhtbeej
Yeh Khula Aasmaan
Love, Wrinkle-free
1
8
Ferrari Ki Sawaari
Qasam Se Qasam Se
Teri Meri Kahaani
Gangs of Wasseypur
29
Bol Bachchan
3 Bachelors
13
Gattu
Challo Driver
Mere Dost Picture Abhi Baki Hai
Kyaa Super Kool Hai Hum
Aalaap
Overtime
Jism 2
Krishna Aur Kans
8
10
15
24
Joker
Jalpari: The Desert Mermaid
From Sydney with Love
I M 24
Raaz 3
Chal Pichchur Banate Hain
Barfi!
Jeena Hai Toh Thok Daal
21
Kamaal Dhamaal Malamaal
Oh My God
English Vinglish
Kismet Love Paisa Dilli
Aiyyaa
Makkhi
Login
Chittagong (film)
Bhoot Returns
Student Of The Year
Delhi Safari
24
Ajab Gazabb Love
Rush
Luv Shuv Tey Chicken Khurana
1920 - Evil Returns
Ata Pata Laapata
Sons Of Ram
Future To Bright Hai Ji
Jab Tak Hai Jaan
Son Of Sardaar
30
7
14
14
21
Chandni Chowk to China
Aasma: The Sky Is the Limit
Raaz – The Mystery Continues
Luck by Chance
Victory
Dev.D
Chal Chala Chal
Mere Khwabon Mein Jo Aaye
Billu
The Stoneman Murders
Delhi-6
Kisse Pyaar Karoon
13B
Dhoondte Reh Jaaoge
Karma Aur Holi
Jai Veeru
Little Zizou
Gulaal
Aloo Chaat
Barah Aana
Firaaq
Lottery
Straight
Aa Dekhen Zara
99
Ek: The Power of One
from bs4 import BeautifulSoup
import requests
def main(link):
source_code = requests.get(link)
plain_text = source_code.text.encode('utf-8')
soup = BeautifulSoup(plain_text, "lxml")
a = []
for table in soup.findAll('table',{'class':'wikitable sortable'}):
for tr in table('tr'):
flag = 0
a.append([])
for td in tr('td'):
if td.get('rowspan') is not None or td.span is not None:
continue
a[-1].append(td.text)
for x in a:
if len(x) > 0:
information.append(x[0])
def get_year_links():
year_list = []
link = 'https://en.wikipedia.org/wiki/Lists_of_Bollywood_films'
source_code = requests.get(link)
plain_text = source_code.text.encode('utf-8')
soup = BeautifulSoup(plain_text, "lxml")
flag = 0
for ul in soup.findAll('ul'):
if ul.parent.get('id') == 'mw-content-text':
for li in ul('li'):
if flag == 19:
break
if li.a.get('href').find('/wiki/') == 0:
year_list.append('https://en.wikipedia.org'+li.a.get('href').strip('\n'))
flag += 1
if flag == 19:
break
del year_list[-1]
return year_list
if __name__ == '__main__':
information = []
years = get_year_links()
for i in years:
main(i)
del information[0]
f = open('Movie_list.txt','w')
for j in information:
f.writelines(j.encode('utf-8')+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment