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 :)

Recommended Answers

All 3 Replies

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

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.

Its from a COM Science past lab test question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.