Essentially i am buliding a card game but i dont know how to read to text file.As well that i need to assign the names with random values .If you could point me to an external website to learn i would be very greatful.
Solved! Solved! Go to Solution.
Welcome to the Github Community Forum!
I can try to solve your problem with some example.
Read text files with Python3.x
with open("<name_of_file>.<extension>", "r") as file_name: lines = file_name.readlines() # now lines represents a list of all lines inside file_name # you can parse this lines with something like this for line in lines: # do something
Assign to variable random values
import random value_int = random.randint(0,100) name_list = ["name1","name2","name3"] value_name = name_list[random.randint(0,len(name_list)-1)]
Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!