How can i hide numbers from my string to not show on print

hey , I have 2 questions regarding the ASCII exercise from the “hello world” class

  1. To present my initials in ASCII format I first created a greed of numbers. for printing the string i created, how can I omit the numbers to be shown on print ? (letter is R, the editing in the txt box is ignoring spaces but in the code its nicely shown as an R )

first_letter="""
1 2 3 4 5
1 rrrrr
2 r___r
3 r___r
4 rrrr
5 r___r
6 r____r
7 r_____r
“”"
print (first_letter)

  1. if ill create in the same way : second_letter variable, who can make it so the output of print will show the initials side by side and not on below the other ?

thanks :slight_smile:

I don’t think there’s a simple way to do part 1 with print alone. You’d want to be modifying the underlying string to create one or more strings that match what you want (namely all the removed numbers). If you’re new to Python you might be better off just editing the actual text rather than testing formatting methods (they’re introduced further along in the course).

Part 2 is a similar issue in that you’d want to be modifying the string but that won’t have been introduced. I’d highly suggest carrying on with the lessons for now if you want to learn how to do this for yourself.

Here’s a quick example of one possible way it could be achieved (but it uses fairly complex options, string methods, loops, zipping iterables and string formatting tools that aren’t introduced for quite a while)-

first_letter="""\ rrrrr r___r r___r rrrr r___r r____r r_____r """ second_letter="""\ rrrrr r___r r___r rrrr r___r r____r r_____r """ for fst_line, snd_line in zip( first_letter.split(), second_letter.split() ): print( f'{fst_line.replace("_", " "):8}' f'{snd_line.replace("_", " "):8}' )

thank you for the clear response , I will take your advice and maybe once completing the more advance lessons i can resume to those initial exercises and try to have another way of output using more advance knowledge :slight_smile:

1 Like