string=input("Please enter string: ") c1=0 c2=0 for i in string: if(i.isdigit()): c1=c1+1 c2=c2+1 print("The number of digits are: ") print(c1) print("The number of characters are: ") print(c2) Output 1: Please enter string: python1234 The number of digits are: 4 The number of characters are: 10 Output 2: Please enter string: program12345 The number of digits are: 5 The number of characters are: 12
इन्हें भी देखें।
- while loop
- for loop
- nested loops
- loop control statements (Break, Continue, Pass)
- if statement
- if-else statement
- if-elif statement
- nested if statement
- range() function
- keywords
- Identifiers (names)
- Literals
- Operators
- punctuatorts
Python Programs के लिये यहाँ click करें।