Neural Sync Active
jan-2026-python-week-7-strings-1
Registry Synced
jan-2026-python-week-7-strings-1
504 words
3 min read
Strings 1
Course: Jan 2026 - Python
Strings 1
Submission deadline has passed for this assignment
Due Apr 01, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
2/2 Passed
Submitted on Apr 01, 2026 at 3:48 AM IST
Private Tests
2/2 Passed
Submitted on Apr 01, 2026 at 3:48 AM IST
**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Check if all the odd indices are alphabets and even indices are digits**
Given a string, check if all the odd indices are alphabets and the even indices are digits.
Note: indices starts from 0.
Template Code(Click to Expand)
def is_odd_indices_alpha_and_even_indices_digits(string: str) -> bool: ''' Given a string, check if all the odd indices are alphabets and the even indices are digits. Note: indices starts from 0. Arguments: string: str - the input string Return: bool - True if all odd indices are alphabets and even indices are digits, else False ''' ...
NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.
Public Tests ( 2/2 )
Case 1
Input:
textis_equal( is_odd_indices_alpha_and_even_indices_digits("a1b2c3"), False ) is_equal( is_odd_indices_alpha_and_even_indices_digits("1a2b3c"), True )
Case 1
Expected Output:
textFalse True
Case 1
Actual Output:
textFalse True
Case 2
Input:
textis_equal( is_odd_indices_alpha_and_even_indices_digits("3x4b6d"), True ) is_equal( is_odd_indices_alpha_and_even_indices_digits("123abc"), False )
Case 2
Expected Output:
textTrue False
Case 2
Actual Output:
textTrue False
Private Tests ( 2/2 )
Case 1
Input:
textis_equal(is_odd_indices_alpha_and_even_indices_digits("0b1h2t"), True) is_equal(is_odd_indices_alpha_and_even_indices_digits("4bn4n5"), False)
Case 2
Input:
textis_equal(is_odd_indices_alpha_and_even_indices_digits("jqn432p5n6"), False) is_equal(is_odd_indices_alpha_and_even_indices_digits("0a1b2d3e"), True) is_equal(is_odd_indices_alpha_and_even_indices_digits("23l45k"), False)
Case 2
Expected Output:
textFalse True False
Case 2
Actual Output:
textFalse True False
💻 IITM Official Solution
pythondef is_odd_indices_alpha_and_even_indices_digits(string: str) -> bool: ''' Given a string, check if all the odd indices are alphabets and the even indices are digits. Note: indices starts from 0. Arguments: string: str - the input string Return: bool - True if all odd indices are alphabets and even indices are digits, else False ''' return string[::2].isdigit() and string[1::2].isalpha()
💻 My Submitted Code
pythondef is_odd_indices_alpha_and_even_indices_digits(string: str) -> bool: # Separate even-indexed and odd-indexed characters using slicing even_chars = string[0::2] odd_chars = string[1::2] # .isdigit() returns True if all characters in the string are digits # .isalpha() returns True if all characters in the string are alphabets # string[0::2] checks indices 0, 2, 4... # string[1::2] checks indices 1, 3, 5... return even_chars.isdigit() and odd_chars.isalpha()