Python Forum
How to append at a specific position
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append at a specific position
#1
This is a little hard to explain but if the code is ran things will start to make sense.

Right now when this program is ran it does this, when I enter a letter in the input that is part of line 1
['*', '*', '*', '*', '*', 'l']

My goal is to have it do this instead
['*', 'l', '*', '*', '*',]


line1 = 'alpha'
line2 = ['*', '*', '*', '*', '*',]
password = input('enter a letter in the password')

for i in line1:
    if i == password:
        line2.append(password)
        print(line2)
Does anyone know the solution?
Reply


Messages In This Thread
How to append at a specific position - by Carson147 - Sep-21-2019, 12:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to append a value to specific excel cell using openpyxl hobbyist 0 4,899 Mar-05-2021, 07:14 PM
Last Post: hobbyist
  Printing string at specific position on terminal - not showing __Mathieu__ 1 2,419 Sep-07-2020, 10:32 AM
Last Post: Larz60+
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 2,638 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Delete specific lines contain specific words mannyi 2 4,179 Nov-04-2019, 04:50 PM
Last Post: mannyi
  [split] How to write at a very specific position of a text file Lalit 1 4,061 Feb-01-2018, 04:44 PM
Last Post: dalwood

Forum Jump:

User Panel Messages

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