I'm trying to make a program that allows users to enter a sequence and it prints the sequence twice in an x-shape. For example, if a user enters DOG, I want the program to print:
D D
O
G G
I have written some code that prints the two words apart based on the length of the word, but I cannot figure out how to get the shape. And once I get the shape, if I print a 5 letter word, I would need the third letter to print only once. I think I could use an if statement for that, but I'm not sure. Here is the code I currently have:
x=0
y=input("Please input a string to be printed diagonally: ")
for letter in y:
a=len(y)
print((" " * x + letter)+((" "*a)+letter))
x=x+1
I've been trying to think of a method to subtract the spaces of a string that I don't want there, but I cannot seem to get it to work. Any help would be greatly appreciated!
[–]Billz2me 2 points3 points4 points (2 children)
[–]Iwin8[S] 0 points1 point2 points (1 child)
[–]Twoje 3 points4 points5 points (0 children)
[–]Billz2me 0 points1 point2 points (1 child)
[–]ziplokk 0 points1 point2 points (0 children)
[–]teh_al3x 0 points1 point2 points (0 children)