The code is quite short so I put it here:
prog = []
# Reading the database from a file
try:
with open('prog.txt') as f:
progA = f.read().splitlines()
for n in range(len(progA)/2):
num = n*2
prog.append([progA[num],progA[num+1]])
except:
print "Something went wrong"
ch = 1
while True:
nR = True
print prog[ch-1][0]
# Getting input
while nR:
inp = raw_input(">>> ")
try:
inp = int(inp)
if str(inp) in prog[ch-1][1]:
ch = inp
nR = False
else:
print "You can't move to that channel"
except:
print "That isn't a number"
And the contents of the file (prog.txt):
DATABASE\nBrowse by entering the number you see after the link.\n> VERSION (3)
23
VERSION\nThis is the latest version.\n> Main menu (1)
1
The code works, but not as I wanted. It prints the newlines as it would be any other text, not with an actual new line.
\nin prog.txt is treated as normal character, thats why!