I've finished writing the encryption code for Caesar cipher in Java and my plan is to rewrite the program using the same logic in Python as well. Although it can be done in many ways, is there any way I can use something equivalent to StringBuilder in Python? If I have a hold variable in Python that stores a string value then how can I append new characters or strings in a way similar done in Java below?
static String encrypt(String s, int shift)
{
shift = shift % 26 + 26;
StringBuilder hold = new StringBuilder();
for (char i : s.toCharArray())
{
if (Character.isLetter(i))
{
if (Character.isUpperCase(i))
hold.append((char)('A' + (i - 'A' + shift) % 26 ));
else
hold.append((char)('a' + (i - 'a' + shift) % 26 ));
}
else
hold.append(i);
}
return hold.toString();
}