Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Last active September 21, 2022 19:52
Show Gist options
  • Select an option

  • Save mayankdawar/bc7d4fc0207e9575efaafbbc1b42e4c8 to your computer and use it in GitHub Desktop.

Select an option

Save mayankdawar/bc7d4fc0207e9575efaafbbc1b42e4c8 to your computer and use it in GitHub Desktop.
Currently there is a string called str1. Write code to create a list called chars which should contain the characters from str1. Each character in str1 should be its own element in the list chars.
str1 = "I love python"
chars = []
for i in str1:
chars.append(i)
@raviprakashram
Copy link

str1 = "I love python"
chars = []
for i in str1:
chars.append(i)

@ayenachewkk
Copy link

Its Working properly
str1 = "I love python"

chars = [ ]
for char in str1 :
chars.append( i )

@hucodelab
Copy link

I did this way

str1 = "I love python"
# HINT: what's the accumulator? That should go here.
chars = []
for i in range(len(str1)):
    chars.append(str1[i])

@Mehabub1629
Copy link

str1 = "I love python"
chars = []
for i in str1:
chars.append(i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment