Помогите с номером на римскую цифру Python скрипт - PullRequest
1 голос
/ 23 января 2012

Я пытаюсь преобразовать числа (до 30) в римские цифры.Используя скрипт для другой функции калькулятора полей в качестве шаблона, я создал этот скрипт, который не хочет работать.Любая помощь будет принята с благодарностью!

def NumberToRomanNumeral ( !CONCESSION! ):
 if CONCESSION == "1":
  newstr = "I"
elif CONCESSION == 2:
 newstr = "II"
elif CONCESSION == 3:
 newstr = "III"    
elif CONCESSION == 4:
 newstr = "IV"    
elif CONCESSION == 5:
  newstr = "V"  
elif CONCESSION == 6:
 newstr = "VI"  
elif CONCESSION == 7:
 newstr = "VII" 
elif CONCESSION == 8:
 newstr = "VIII"  
elif CONCESSION == 9:
 newstr = "IX"  
elif CONCESSION == 10:
 newstr = "X" 
elif CONCESSION == 11:
 newstr = "XI"
elif CONCESSION == 12:
 newstr = "XII"
elif CONCESSION == 13:
 newstr = "XIII"
elif CONCESSION == 14:
 newstr = "XIV"
elif CONCESSION == 15:
 newstr = "XV"
elif CONCESSION == 16:
 newstr = "XVI"
elif CONCESSION == 17:
 newstr = "XVII"
elif CONCESSION == 18:
 newstr = "XVIII"
elif CONCESSION == 19:
 newstr = "XIX"
elif CONCESSION == 20:
 newstr = "XX"
elif CONCESSION == 21:
 newstr = "XXI"
elif CONCESSION == 22:
 newstr = "XXII"
elif CONCESSION == 23:
 newstr = "XXIII"
elif CONCESSION == 24:
 newstr = "XXIV"
elif CONCESSION == 25:
 newstr = "XXV"
elif CONCESSION == 26:
 newstr = "XXVI"
elif CONCESSION == 27:
 newstr = "XXVII"
elif CONCESSION == 28:
 newstr = "XXVIII"
elif CONCESSION == 29:
 newstr = "XXIX"
elif CONCESSION == 30:
 newstr = "XXX"


else:
   newstr = ""
return newstr

1 Ответ

1 голос
/ 25 января 2012

Восклицательные знаки находятся не в том месте - должно быть

Выражение:

NumberToRomanNumeral(!CONCESSION!)

Блок кода: начало ...

def NumberToRomanNumeral(CONCESSION):
...