Last active
April 3, 2024 19:46
-
-
Save orjanv/9d9950eb49a3ee21982f73b37b058a5e to your computer and use it in GitHub Desktop.
Et lite python program for å gjøre om ord eller setninger til tall, basert på alfabetiske posisjoner for hver bokstav.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
alfabet = "abcdefghijklmnopqrstuvxyzæøå" | |
tallrekke = [] | |
try: | |
setning = sys.argv[1] | |
except: | |
setning = input("Skriv noe du vil konvertere til alfabetisk posisjon: ") | |
setning = setning.lower() | |
for i in setning: | |
try: | |
tallrekke.append('.' if i == ' ' else alfabet.index(i) + 1) | |
except ValueError: | |
pass | |
print(' '.join(map(str, tallrekke))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment