Python decryption of Caesar Cipher
Don't use meaningless names like &quot;napis&quot; and &quot;wynik&quot;.
x and i are meaningful in some contexts, but not for what you're using them, so use better names for those as well.
You could take advantage of negative indices, i.e., remove ALPHABET[i+x] if i+x&lt;len(ALPHABET) else  and just use ALPHABET[i+x-len(ALPHABET)]. Or, more generally, ALPHABET[(i+x) % len(ALPHABET)].
You could assume that spaces are the most frequent characters and do x = ALPHABET.index(' ') - max(napis, key=napis.count) instead of the loop.