How do I convert user input into a list?

Peter Yost

I'm wondering how to take user input and make a list of every character in it.

magicInput = input('Type here: ')

And say you entered "python rocks" I want a to make it a list something like this

magicList = [p,y,t,h,o,n, ,r,o,c,k,s]

But if I do this:

magicInput = input('Type here: ')
magicList = [magicInput]

The magicList is just

['python rocks']
gtlambert

Use the built-in list() function:

magicInput = input('Type here: ')
magicList = list(magicInput)
print(magicList)

Output

['p', 'y', 't', 'h', 'o', 'n', ' ', 'r', 'o', 'c', 'k', 's']

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

  1. 1

    How to return a single asset OhMyBrew Laravel Shopify

  2. 2

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    pump.io port in URL

  6. 6

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  7. 7

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  8. 8

    Make a B+ Tree concurrent thread safe

  9. 9

    Group boxplot data while keeping their individual X axis labels in ggplot2 in R

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  12. 12

    BigQuery - concatenate ignoring NULL

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  15. 15

    Razor Page - How to redirect to another folder's page using asp-for tag helper

  16. 16

    "django.db.utils.ProgrammingError: relation "auth_user" does not exist" Django V2.0

  17. 17

    How to exclude a specific git submodule from update?

  18. 18

    how to fix CMake Error in CMakeLists.txt: Generator NMake Makefiles does not support platform specification, but platform x64 was specified

  19. 19

    Is there a way to ask the user before loading the website

  20. 20

    How to remove the extra space from right in a webview?

  21. 21

    Optimising manipulation of large vectors

HotTag

Archive