just met this question online trying to run it am getting memory error. any idea?
inputs= ['nodejs','reactjs','vuejs']
print(inputs)
for i in inputs:
inputs.append(i.upper())
print(inputs)
CodePudding user response:
You are making an infinite loop. You should do this instead:
inputs= ['nodejs','reactjs','vuejs']
print(inputs)
upper_inputs = []
for i in inputs:
upper_inputs.append(i.upper())
print(upper_inputs)
or even better:
inputs = ['nodejs','reactjs','vuejs']
print(inputs)
upper_inputs = list(map(lambda x: x.upper(), inputs))
print(upper_inputs)