I am working on a python program. I want to take a user input which is less then 140 characters. If the sentence exceeds the word limit, It should just print the 140 characters. I am able to enter characters but this is what happens. I am new to python. How can I achieve this?
def isAlpha(c):
if( c >= 'A' and c <='Z' or c >= 'a' and c <='z' or c >= '0' and c <='9'):
return True
else:
return False
def main():
userInput = str(input("Enter The Sentense: "))
for i in range(140):
newList = userInput[i]
print(newList)
this is the output i get
Enter The Sentense: this is
t
h
i
s
i
s
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
main()
File "C:/Users/Manmohit/Desktop/anonymiser.py", line 11, in main
newList = userInput[i]
IndexError: string index out of range
Thank you for the help