Write a Python program that creates upside down sentences, like
upside down --> umop apisdn

The sentence above is flipped 180 degrees around the end.
Some freedom allowed, like an 'a' upside down and reversed is the closest thing to an 'e'. Conversely a 'w' would be a 'm' upside down.

Note:
A silly little thing originally in "Beginners Projects". I moved it here because Tony had such a nice solution.

TrustyTony commented: Unclear, if not wrong, rule of request +0

Recommended Answers

All 3 Replies

I do not understand the rule:

for c in 'umop apisdn':
	print c,'upside down'.find(c)
	
u 0
m -1
o 8
p 1
  6
a -1
p 1
i 3
s 2
d 4
n 10

So 'm' and 'a' is not in other string at all.

Write a Python program that creates upside down sentences, like
upside down --> umop apisdn

The sentence above is flipped 180 degrees around the end.
Some freedom allowed, like an 'a' upside down and reversed is the closest thing to an 'e'. Conversely an 'w' would be an 'm' upside down.

Well corrected description, here is little advanced beginners answer with conditional value ('*' if letter is not found in upside down letter dictionary)

##upside down --> umop apisdn
def upside(instring):
    upside_dict = {'u':'n','n':'u',
                   'p':'d','d':'p',
                   's':'s',' ':' ',
                   'o':'o','i':'i',
                   'h':'y', 'y':'h',
                   'a':'e', 'e':'a',
                   'w':'m','m':'w',
                   '6':'9','9':'6', '1':'1','0':'0',
                   }
    return ''.join([(upside_dict[char] if char in upside_dict else '*') for char in instring[::-1]])


for instring in ('upside down','daniweb'):

    print instring,'->',upside(instring)

Maybe it is not proper to post code here as answer? Sorry about above post, but I felt compelled to post it after my request for clarification. You can remove it and the request.

Note:
Thanks for spending some time with this! Moved it to the regular forum.

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.