Python Forum

Full Version: beginner help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I just started python with THONNY IDE.

I have a sample code for remove 'n' th character.

Tested it works fine, then i edit the code for remove 'x' and 'y' character, at that time i am getting error at Line No. 19.
can someone tell me, what is going wrong ?

# Python code to demonstrate 
# method to remove i'th character 
# Naive Method 

# Initializing String 
test_str = "electronics"

# Printing original string 
print ("The original string is : " + test_str) 

# Removing char at pos 3 
# using loop 
new_str = "" 

for i in range(0, len(test_str)): 
    if i != 5: 
        new_str = new_str + test_str[i] 

for i in range(0, len(new_str))      #error at this line
    if i != 7:
        new_str1 = new_str1 + new_str[i]
        
        new_str = new_str1
        
# Printing string after removal 
print ("The string after removal of i'th character : " + new_str)
on line 19 there is missing colon :
(Nov-19-2019, 02:49 PM)buran Wrote: [ -> ]on line 19 there is missing colon :

Thanks buran