Welcome to my Website!

This is a paragraph! Here's how you make a link: Neocities.

Here's how you can make bold and italic text.

Here's how you can add an image:

Here's how to make a list:

To learn more HTML/CSS, check out these tutorials!

import random class Serial: #record structure def __init__(self): self.title = "" self.incarnation = 0 self.ep_count = 0 def read(): file = open("DoctorWhoCSV.txt", "r") #open file serials = [] #set up array of records for line in file: #loop through records in file data = line.split(",") nextSerial = Serial() nextSerial.title = (data[0]) nextSerial.incarnation = int(data[1]) nextSerial.ep_count = int(data[2]) #populating record serials.append(nextSerial) file.close() return serials #returns array of records def findSerials(AllSerials): incarnation_input = input("Enter an incarnation (or press Enter to skip): ") if incarnation_input: userIncarnation = int(incarnation_input) else: userIncarnation = None ep_count_input = input("Enter a number of episodes (or press Enter to skip): ") if ep_count_input: userEp_count = int(ep_count_input) else: userEp_count = None matching_titles = [] for serial in AllSerials: # loop through array of records if ((userIncarnation is None or serial.incarnation == userIncarnation) and (userEp_count is None or serial.ep_count == userEp_count)): matching_titles.append(serial.title) # add matching title to the list return matching_titles def randomiser(matching_titles, No_of_suggestions): if matching_titles: return random.sample(matching_titles, min(len(matching_titles), No_of_suggestions)) # randomly selects titles else: return "No matching titles found." def display_matching_titles(matching_titles): if matching_titles: print("All matching titles:") for title in matching_titles: print(title) else: print("No matching titles found.") #main serials = read() #call read function matching_titles = findSerials(serials) No_of_suggestions = int(input("Enter the number of suggestions you want: ")) suggestions = randomiser(matching_titles, No_of_suggestions) # get a random suggestion print("Suggested titles:") for title in suggestions: print(title) show_all = input("Would you like to see all the stories which fit those parameters? (yes/no): ").strip().lower() if show_all == 'yes': display_matching_titles(matching_titles)