Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner help
#1
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)
Reply
#2
on line 19 there is missing colon :
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

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

Thanks buran
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020