I'm writing a GUI that will generate a random names for taverns for some tabletop gameplay. I have .txt docs that have something like this.
Red
Green
Yellow
Resting
Young
And
King
Dragon
Horse
Salmon
I'm reading and randomly joining them together using the following
x = 1
tavern1 = open('tavnames1.txt', 'r')
name1 = tavern1.readlines()
tav1 = random.sample(name1, int(x))
tav1 = str(tav1)
tav1 =tav1.strip()
tav1 =tav1.replace('\n', '')
tavern2 = open('tavnames2.txt', 'r')
name2 = tavern2.readlines()
tav2 = random.sample(name2, int(x))
tav2 = str(tav2)
TavernName = 'The' + tav1 + tav2
print(TavernName)
The output I get will look something like
The['Young\n']['Salmon\n']
I've tried using .replace() and .strip() on the string but it doesn't seem to work.
Any ideas?
Cheers.