[Tutor] Translate word to number

ivantham@raspberrypi ivanthamjunhoe at gmail.com
Thu Oct 24 12:57:18 CEST 2013


Hi, I'm new to programming. I'm using python 3 and Debian Linux. My
name is Ivan. I'm bad in for loops, I can't complete the following code:

> input_word = input("Word to translate -->  ")

How to change this to for loops?
> a, b, c, d, e, f, g, h = 1, 2, 3, 4, 5, 6, 7, 8                                
> i, j, k, l, m, n, o, p = 9, 10, 11, 12, 13, 14, 15, 16                         
> q, r, s, t, u, v, w, x, y, z = 17, 18, 19, 20, 21, 22, 23, 24, 25, 26

How to change the word to number in for loops?
> for words in input_word:
>     words[0] = number[1]      # The loops before in a to z
>     word += 1                 # Change the word from a to z
>     number += 1               # And the number to so that 1 = a, 2 = b
>                               # Then, add the numbers together

How to take the output to a .txt file with new line for each word with
numbers in this format?
  eg. abc = 6
  eg. good = 41
> delimeter = " = "  # for joining the input word and number
> together
> line = input_word + delimeter + number  # save as this format

Thanks, sorry for my English as English is not the main language that I
speak.



More information about the Tutor mailing list