Skip to content

Instantly share code, notes, and snippets.

@ledakis
Last active April 19, 2017 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ledakis/c2be1102549153d0fed2463b996ddd41 to your computer and use it in GitHub Desktop.
Save ledakis/c2be1102549153d0fed2463b996ddd41 to your computer and use it in GitHub Desktop.
Return character/index of a string
#!/usr/bin/env python3
# Returns the position in the string of a character
# made this because I used a generated passphrase
# on my bank's website and keeps asking me which
# is the 15th character and it is so annoying :)
# Not special, just outputs the thing, not optimised.
line1=line2="|"
newline="\n"
extraspace=""
string=input('enter string'+newline)
for index in range(len(string)):
line1+=str(index+1)+"|"
line2+=" "*(len(str(index+1))-1)+string[index]+"|"
print()
print(line1+newline+line2)
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment