I am trying to get this output:
+-+-+-+-+-+-+
|P|Y|T|H|O|N|
+-+-+-+-+-+-+
Is it possible to get that output without adding new lines in the code?
def art(name):
for i in range(len(name[0]), len(name) + 1):
head = "+" + i * "-+"
middle = "|" + i * "{}|".format(name[0].upper())
bottom = "+" + i * "-+"
print(head + "\n" + middle + "\n" + bottom)
art("Python")
Actual output:
+-+-+-+-+-+-+
|P|P|P|P|P|P|
+-+-+-+-+-+-+
I can't figure out how to manipulate it in order to get it to work. I've tried to use use index() and i as a variable but I get errors such as: "IndexError: string index out of range"
print(repr(i))into the loop or, even more useful, learn to use a debugger to step through the code. For the latter, try to find video tutorials for your IDE. As a new user here, please also take the tour and read How to Ask.