0

I already know how to delete strings, but the question here is: How do you delete them in a certain order without typing its value, for example, "Mathew", but I want to remove it without actually typing "Mathew" and without removing the value "Paul"? Is there a way behind this?

Note that "Paul" is the first string in the list, so I do not want to remove this, but the second string if it is possible.

usernames = ["Paul", "Mathew"]
del_username = usernames.remove("Mathew")

I have tried adding a '1' to the .remove function, but it can't find the value somehow.

del_username = usernames.remove(1)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

1 Answers1

0

To remove the item at index i, use del

names = ["Paul", "Mathew"]
del names[1]
print(names)

outputs

["Paul"]
Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96