Python3 code to demonstrate working of Extract String till Numeric Using isdigit() + index() + loop


Topic: Python3 code to demonstrate working of Extract String till Numeric Using isdigit() + index() + loop

Solution

test_str = "geeks4geeks is best"
print("The original string is : " + str(test_str)) 
temp = 0
for chr in test_str: 
    if chr.isdigit(): 
        temp = test_str.index(chr) 
print("Extracted String : " + str(test_str[0 : temp])) 



List all Python Programs