python - add word with each number in one line -



python - add word with each number in one line -

i made var input word , output of word encode hex , need made var number if input 10 , output = 1,2,3,4,5,6,7,8,9,10 , need bring together word each number .. output , hexedword1,hexedword2,hexedword3 ... etc .. here code

num = raw_input("inset number of students. ") num in range(1, num + 1) print num word = raw_input("insert name of pupil encrypt hex. ") res = "0x" + word.encode('hex') + num print res

it's little hard tell asking, understand, encrypted pupil names separated commas number next name

there few errors code. one, raw_input("inset number of students. ") returns string, utilize integer. prepare this, num = int(raw_input("inset number of students. ")) there farther things can maintain user giving weird, work.

another problem res. each student, res beingness reset. want info added it. done += operator, if want them separated commas, best thing can think of using array can joined commas later on.

all together, code this:

num = int(raw_input("inset number of students. ")) res = [] num in range(1, num + 1): print num word = raw_input("insert name of pupil encrypt hex. ") res.append("0x" + word.encode('hex') + str(num)) print ",".join(res)

personally, using num both iterator of loop num feels weird, i'll allow maintain that.

python

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -