The PERFECT Script For TROLLING In Python #code #programming #python 学習 Twitter Facebook はてブ Pocket LINE コピー 2023.10.15 2023.10.14 This is the perfect script for trolling in Python. #code #programming #python
コメント
return ”.join((c.lower if i % 2 else c.upper)() for i, c in enumerate(s))
Why loop if it’s exactly when comprehensions are used?
Making it a 1 liner is actually more readable than the split up code lol
return ”.join([c.upper() if i % 2 == 0 else c.lower() for i, c in enumerate(s)])
Instead of using a list, you can use another string initialized by ”.
def alt_caps(in_str):
out_str = ”
for i, c in enumerate(in_str):
if i % 2:
out_str += c.lower()
else:
out_str += c.upper()
return out_str