Python Forum
beginner help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: beginner help (/thread-22602.html)



beginner help - ksoni - Nov-19-2019

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)



RE: beginner help - buran - Nov-19-2019

on line 19 there is missing colon :


RE: beginner help - ksoni - Nov-20-2019

(Nov-19-2019, 02:49 PM)buran Wrote: on line 19 there is missing colon :

Thanks buran