http://codechillout.sphere-contest.com/problems/onlineround/HTMLTAGS
HTML tags
We often write HTML tags with both lower-case and capital letters. As a result, the website’s source code looks ugly. Your task is to write a program which will turn all the lowe-case letters in the HTML tags (i.e. those appearing in between of the signs “<” a “>”) into capital letters.
Input
You are given a fragment of HTML source code.
Output
Your output should print the same HTML source code, but with all the HTML tags written in capital letters.
Example
Input: <html> <head> <TITLE>This is title</Title> </head> <body> <b>Something</b> </body> </html> Output: <HTML> <HEAD> <TITLE>This is title</TITLE> </HEAD> <BODY> <B>Something</B> </BODY> </HTML>
Answer
import fileinput for line in fileinput.input(): res = ''; for c in line: if(c == '< '): flag = True elif(c == '>'): flag = False if(flag == False): res += c elif(flag == True): res += c.upper() print res