Skip to content

Instantly share code, notes, and snippets.

@AnBucquet
Created April 14, 2020 10:27
Show Gist options
  • Select an option

  • Save AnBucquet/c3d9cd6959c091df66432b4c7be409f3 to your computer and use it in GitHub Desktop.

Select an option

Save AnBucquet/c3d9cd6959c091df66432b4c7be409f3 to your computer and use it in GitHub Desktop.
# Solution one
a='AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
t=input().replace(' ','')
x = [c for c in t if not c.isalpha()]
b = [c for c in t if c.isalpha()]
s = sorted(b,key=lambda c:a.index(c))
# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr)
print(''.join(s)+''.join(x))
# Solution two
entry = input().replace(" ","")
order = sorted(set(entry.lower()))
t=""
for l in order:
if l.isalpha():
t+=(l.upper())*entry.count(l.upper())+(l)*entry.count(l)
for l in entry:
if not l.isalpha():
t+=l
print(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment