我有一个变量可以容纳一个字母。为了有一个具体的例子,我们假设它是“A”。
我有一个while循环,在某些情况下,它会将该变量更改为下一个字母(“b”,在本例中)。
我想知道如何在Python中实现这一点:
Pseudocode:
char = 'A'
next_char = 'A' + 1
Python:
letter = 'A'
next_letter = 'A' + 1 # This fails with error TypeError: can only concatenate str (not "int") to str