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..

Oh sorry..


It works best to open it with wordpad..

:D

Attachments
_______ 
(  ___  )
| (   ) |
| (___) |
|  ___  |
| (   ) |
| )   ( |
|/     \|
 ______  
(  ___ \ 
| (   ) )
| (__/ / 
|  __ (  
| (  \ \ 
| )___) )
|/ \___/ 
 _______ 
(  ____ \
| (    \/
| |      
| |      
| |      
| (____/\
(_______/
 ______  
(  __  \ 
| (  \  )
| |   ) |
| |   | |
| |   ) |
| (__/  )
(______/ 
 _______ 
(  ____ \
| (    \/
| (__    
|  __)   
| (      
| (____/\
(_______/
 _______ 
(  ____ \
| (    \/
| (__    
|  __)   
| (      
| )      
|/       
 _______ 
(  ____ \
| (    \/
| |      
| | ____ 
| | \_  )
| (___) |
(_______)
         
|\     /|
| )   ( |
| (___) |
|  ___  |
| (   ) |
| )   ( |
|/     \|
_________
\__   __/
   ) (   
   | |   
   | |   
   | |   
___) (___
\_______/
_________
\__    _/
   )  (  
   |  |  
   |  |  
   |  |  
|\_)  )  
(____/   
 _       
| \    /\
|  \  / /
|  (_/ / 
|   _ (  
|  ( \ \ 
|  /  \ \
|_/    \/
 _       
( \      
| (      
| |      
| |      
| |      
| (____/\
(_______/
 _______ 
(       )
| () () |
| || || |
| |(_)| |
| |   | |
| )   ( |
|/     \|
 _       
( (    /|
|  \  ( |
|   \ | |
| (\ \) |
| | \   |
| )  \  |
|/    )_)
 _______ 
(  ___  )
| (   ) |
| |   | |
| |   | |
| |   | |
| (___) |
(_______)
 _______ 
(  ____ )
| (    )|
| (____)|
|  _____)
| (      
| )      
|/       
 _______ 
(  ___  )
| (   ) |
| |   | |
| |   | |
| | /\| |
| (_\ \ |
(____\/_)
 _______ 
(  ____ )
| (    )|
| (____)|
|     __)
| (\ (   
| ) \ \__
|/   \__/
 _______ 
(  ____ \
| (    \/
| (_____ 
(_____  )
      ) |
/\____) |
\_______)
_________
\__   __/
   ) (   
   | |   
   | |   
   | |   
   | |   
   )_(   
         
|\     /|
| )   ( |
| |   | |
| |   | |
| |   | |
| (___) |
(_______)
         
|\     /|
| )   ( |
| |   | |
( (   ) )
 \ \_/ / 
  \   /  
   \_/   
         
|\     /|
| )   ( |
| | _ | |
| |( )| |
| || || |
| () () |
(_______)
         
|\     /|
( \   / )
 \ (_) / 
  ) _ (  
 / ( ) \ 
( /   \ )
|/     \|
         
|\     /|
( \   / )
 \ (_) / 
  \   /  
   ) (   
   | |   
   \_/   
 _______ 
/ ___   )
\/   )  |
    /   )
   /   / 
  /   /  
 /   (_/\
(_______/

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.

Comments
I agree

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.

Edited 7 Years Ago by woooee: n/a

This article has been dead for over six months. Start a new discussion instead.