Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to make sure the input length is a multiple of 16, and if not add padding to it

$
0
0

basically i want to have an inputted message, and if it is not a value of 16 add random letters to it to make its length a multiple of 16

this is my current code:

import maths = "IYGGRTOCTOERGTDKHUTAOHEIIATTOICNNRIHDSRGKENEACA!"i = 16rows = [s[x:x+i] for x in range(0, len(s), i)]    #print('\n'.join(rows))columns = list(zip(*rows))print i, columns

This does nothing fancy and insteadjust splits the input up every 16 characters and takes the first letter from each coulmn then outputs it etc, a very basic transpoistion cypher

so what i am trying to do it figure out if s is a multiple of 16, and if not add some random letters to s until it isso how can i achieve this in python ?

thanks guys


Viewing all articles
Browse latest Browse all 23131

Trending Articles