0

Whats up Guys?

How do you make this program work for all string inputs?
It reads only 5 and 6 letter words and outputs it in an X formation.

1) For example: Input
Hello

Output:
H o
e l
l
e l
H o

2) For example: Input:
Doctor

Output:
D r
o o
ct
ct
o o
D r


Here's my Code:

H= raw_input()
if len(H)==5:
	Space = " "	
	A,B,C,D,E = H
	for i in range(1):
		print A+Space*3+E
		print Space+B+Space+D+Space
		print Space*2+C+Space*2
		print Space+B+Space+D+Space
		print A+Space*3+E
else:
	if len(H)==6:
		A,B,C,D,E,F = H
	Space = " "
	for i in range(1):
		print A+Space*3+F
		print Space+B+Space+E+Space
		print Space*1+C+D+Space*1
		print Space*1+C+D+Space*1
		print Space+B+Space+E+Space
		print A+Space*3+F

Thanks :)

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by diniboi
0
Input: Hello
Output:
H   o
 e l
  l
 e l
H   o

Input: Doctor
Output:
D    r
 o  o
  ct
  ct
 o  o
D    r
0

What is the purpose of this code? If it has a legitimate purpose then I will respond, but if you are just yanking our chain, then please don't abuse the volunteers' time. A hint: divide the length by 2 and print the first half and second half, although you will have to adjust for a string who's length is an odd number.

Edited by woooee: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.