A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a Python program to count characters at same position in a given string (lower and uppercase characters) as in English alphabet.
Q:

Write a Python program to count characters at same position in a given string (lower and uppercase characters) as in English alphabet.

0

 Write a Python program to count characters at same position in a given string (lower and uppercase characters) as in English alphabet.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def count_char_position(str1): 
    count_chars = 0
    for i in range(len(str1)):
        if ((i == ord(str1[i]) - ord('A')) or 
            (i == ord(str1[i]) - ord('a'))): 
            count_chars += 1
    return count_chars 
  
str1 = input("Input a string: ")
print("Number of characters of the said string at same position as in English alphabet:")
print(count_char_position(str1))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now