list = ['helloXXX', 'welcomeXXX', 'to999', 'SofthuntUUU']
replace = [list.replace('XXX', 'ZZZ') for list in list]
print(replace)
# Replace 'Koweit' To 'Sudan'
my_list = [ "Egypt", "Koweit", "Algeria", "Morocco", "Tunisia" ]
my_list[ 1 ] = "Sudan"
print( my_list )
# Replace a particular item in a Python list
a_list = ['aple', 'orange', 'aple', 'banana', 'grape', 'aple']
for i in range(len(a_list)):
if a_list[i] == 'aple':
a_list[i] = 'apple'
print(a_list)
# Returns: ['apple', 'orange', 'apple', 'banana', 'grape', 'apple']
# Replace Values in a List using Slicing
# define list
l = ['Hardik', 'Rohit', 'Rahul', 'Virat', 'Pant']
# find the index of Rahul
i = l.index('Rahul')
# replace Rahul with Shikhar
l = l[:i]+['Shikhar']+l[i+1:]
# print list
print(l)