2
    keyword = raw_input ("Enter your keyword") *10000
keyword = keyword.lower()
keywordoutput = []
for character in keyword:
    number = ord(character) 
    keywordoutput.append(number)


input1 = raw_input('Write Text: ')
input1 = input1.lower()
output1 = []
for character in input1:
    number = ord(character)
    output1.append(number)


output2 = [x + y for x, y in zip(output1, keywordoutput)]
print output2

That is my code so far. I am trying to create a program that uses a simple Vigenere Cypher to encrypt an inputted text. The code works perfectly, yet I am having an issue implimenting new code to return a string of 'output2'.

I get 'output2' easily, but from there i need to make it a simple string. Eg: [1, 2, 3, 4] becomes (1234)

I have tried, but I cant seem to implement such a thing into my code.

Mangu Singh Rajpurohit
  • 10,806
  • 4
  • 68
  • 97

3 Answers3

2

First you have to convert numbers into text.

output2 = map(str, output2)

Then you can use join to concatenate elements.

print "".join(output2)

Or in one line:

print "".join(map(str, output2))
furas
  • 134,197
  • 12
  • 106
  • 148
0

One step use -> join:

output2 = ''.join([str(x + y) for x, y in zip(output1, keywordoutput)])

Check: https://docs.python.org/2/library/string.html#string.join

As the function is expecting a string type you must covert the numeric result x + y.

Juan Diego Godoy Robles
  • 14,447
  • 2
  • 38
  • 52
0

try this

print ''.join(str(i) for i in output2)