Limitando a entrada do usuário para um intervalo em Python
No código abaixo, você verá pedindo um valor 'shift'. Meu problema é que eu quero limitar a entrada de 1 a 26.
For char in sentence:
if char in validLetters or char in space: #checks for
newString += char #useable characters
shift = input("Please enter your shift (1 - 26) : ")#choose a shift
resulta = []
for ch in newString:
x = ord(ch) #determines placement in ASCII code
x = x+shift #applies the shift from the Cipher
resulta.append(chr(x if 97 <= x <= 122 else 96+x%122) if ch != \
' ' else ch) # This line finds the character by its ASCII code
Como faço isso facilmente?