I'm very new to python, as you will discover with my newb question, I am trying to create a project that prints out Ascii Banners EG

_________ _________ _______ _______ _______
|\ /|\__ __/ \__ __/|\ /|( ____ \( ____ )( ____ \
| ) ( | ) ( ) ( | ) ( || ( \/| ( )|| ( \/
| (___) | | | | | | (___) || (__ | (____)|| (__
| ___ | | | | | | ___ || __) | __)| __)
| ( ) | | | | | | ( ) || ( | (\ ( | (
| ) ( |___) (___ | | | ) ( || (____/\| ) \ \__| (____/\
|/ \|\_______/ )_( |/ \|(_______/|/ \__/(_______/

Its meant to say HI THERE,lol.

I have the a txt file with all characters on it, but i'm not sure where to go forward from there..

Well then, what does your text file have in it? Could you post an example please?

Oh sorry..


It works best to open it with wordpad..

:D

Member Avatar for leegeorg07

i would say you would need to save each one in a different file, and then open each one, using .readlines().

and then use a for loop, to iterate over each one, printing line after line of it all together?

I am very keen to stick with the one file, i am sure that there is a way to complete this with just the one file. Anyone?

I can help you, but I can't write the code for you, so

Step 1: build a python list containing all the lines of the file and print it.
Step 2: remove the trailing \r\n at the end of each line
Step 3: how can your program find the lines corresponding to the letter M in the list ? Print these lines.

commented: I agree +8

I'm very new to python,

Depends entirely on your level of knowledge. If you understand dictionaries, then that would be the easiest to understand. The dictionary key would be the letter, pointing to a list of values. For any letter, list_value[0] would be the first line, list_value[1] the second, etc. So if you want to print "HELLO", you would use

string_to_print = "HELLO"
for row in range(0, num_rows_for_any_letter):
   row_to_print = ""
   ##---  print next row for each letter
   for letter in string_to_print:
      row_to_print +=  letter_dict[letter][row] + " "
   print row_to_print

You would of course have to check each letter to make sure it is in the dictionary, as well as for less than the maximum letters that will fit on one page.

As far as your text file goes, you would have to cut and paste that into the dictionary, or read it and test for an empty line, which would indicate the next letter. Each record in the file would become a separate row in the dictionary's value list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.