954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Standard Input and OUTPUT in X formation !!!

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

diniboi
Newbie Poster
9 posts since Apr 2011
Reputation Points: 10
Solved Threads: 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
diniboi
Newbie Poster
9 posts since Apr 2011
Reputation Points: 10
Solved Threads: 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.

woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

Its from a COM Science past lab test question

diniboi
Newbie Poster
9 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: