'in python how can i add a list of numbers
im new to python and know nothing does anyone know how to
Solution 1:[1]
This scratch project has a list variable named "Valid Words". In the orange "Variables" section of the blocks menu, you'll see light orange scalar variables and light orange blocks which operate on scalar variables, followed by dark orange list variables and dark orange blocks which operate on list variables. Check the box next to a variable to make it appear on the editor's graphical display, making it easier to view or edit the variable's initial value(s).
Solution 2:[2]
It is possible to pre-fill a list. This content becomes part of the project, and will be instantly available to anyone visiting the project.
First of all, find the list block in the list of available blocks (the panel to the left of the code area). Turn on the checkbox in front of the list block. This will make the list visible on the stage. (Once we are done, you can turn this off again.)
Now there are two ways to populate the list.
- Manually. Click the
+
at the bottom left corner of the list. Enter a word. Repeat this as often as necessary. - Import. Right-click the list. From the context menu, select import. From the file dialog, select a text file you prepared with a list of words; each word on a separate line.
Given the number of 5-letter words (10,658 in the project you linked to), I'd recommend approach #2.
Tip: you could export the list of words from the project you linked to, and import that list into your own project. Please do not forget to give credit.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | aschepler |
Solution 2 | Ruud Helderman |