this prints all five iterations. cani make it only print the last iteration?
key1 = [' ','a','b','c','0','1','2','3']
out = ''
inpt = raw_input('enter text:')
for i in inpt:
if i in key1:
out = out + key1[key1.index(i)+3]
print out
this prints all five iterations. cani make it only print the last iteration?
key1 = [' ','a','b','c','0','1','2','3']
out = ''
inpt = raw_input('enter text:')
for i in inpt:
if i in key1:
out = out + key1[key1.index(i)+3]
print out
Simply unindent the last line out of the 'for' loop
key1 = [' ','a','b','c','0','1','2','3']
out = ''
inpt = raw_input('enter text:')
for i in inpt:
if i in key1:
out = out + key1[key1.index(i)+3]
print out
Also you should check the value of this statement
out = out + key1[key1.index(i)+3]
to make sure that key1.index(i)+3 isn't greater than the length of the list, key1.
the keys length dosent really matter right now, this was just a test for functionality. but thank you for the post any way that would have been a valid point. i will try moving the print statement, thanks again. so i ralised what i retard i am why i even had the print function inside the loop to begin with is beyond me. i was tired when i started this and had just finished an alpha only encryption program and was wanting to move to alpha numerics and fill spaces with somthing other than white space. so any way thanks for pointing that out, i feel retarded lol
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.