For example, if I type "S" the length should count to 1, and at the end when I finish the word "Stack" the length must be given 5.
            Asked
            
        
        
            Active
            
        
            Viewed 204 times
        
    -1
            
            
        - 
                    2More information. *Where* are you typing the string? How is python involved with that? – Green Cloak Guy Mar 20 '20 at 03:44
- 
                    In python you can use: len(string) But not sure where are you typing and how are you passing value to python – Harpal Mar 20 '20 at 04:13
- 
                    I am trying to make a password program. Suppose you type a password for a Wi-Fi network, then after 8 characters the password button is enabled. I want to do that. – Manas Purandare Mar 20 '20 at 08:16
- 
                    1How are you reading the input? If you're using `input()` then it won't work. – user202729 Sep 22 '20 at 07:01
- 
                    Depends on what you need exactly, [python - Taking input from sys.stdin, non-blocking - Stack Overflow](https://stackoverflow.com/questions/21791621/taking-input-from-sys-stdin-non-blocking) may work. Or search for a TUI library. Otherwise just prompt the user for a different password in a loop. – user202729 Sep 22 '20 at 07:04
1 Answers
0
            
            
        You can use the len() to get the length of string.
    >>> s=input('Enter a string- ')
    Enter a string- stack
    >>> len(s)
    5
Then you can use a loop to check the length every time.
x='yes'
while True:
   my_string=input('Enter a string- ')
   length=len(my_string)
   x=input(f'It is of length {length}....Enter yes/no to continue...  ').lower()
   if x =='no':
     break
   elif x not in ('yes','no'):
     print('\nPlease enter only yes or no (yes/no)....\n')
print('exited')
 
    
    
        teddcp
        
- 1,514
- 2
- 11
- 25
 
    