Python Forum
creating a list during program execution.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
creating a list during program execution.
#2
Totally. Very common operation:

# file to list
data = open('data_file.txt').readlines()

# string to list
text = input('Type in a sentence: ')
words = text.split()

# build from numbers
fib = [1, 1]
for index in range(100):
    fib.append(fib[-1] + fib[-2])
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: creating a list during program execution. - by ichabod801 - Jan-26-2019, 02:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  kill python execution program lebossejames 0 290 Mar-16-2024, 11:16 AM
Last Post: lebossejames
  Program to find Mode of a list PythonBoy 6 1,221 Sep-12-2023, 09:31 AM
Last Post: PythonBoy
  Class-Aggregation and creating a list/dictionary IoannisDem 1 1,975 Oct-03-2021, 05:16 PM
Last Post: Yoriz
  creating simplex tableau pivot program easy or difficult for a beginner in Python? alex_0 2 2,638 Mar-31-2021, 03:39 AM
Last Post: Larz60+
  Creating list of lists from generator object t4keheart 1 2,246 Nov-13-2020, 04:59 AM
Last Post: perfringo
  Creating a dictionary from a list Inkanus 5 3,240 Nov-06-2020, 06:11 PM
Last Post: DeaD_EyE
  Creating a list of dictionaries while iterating pythonnewbie138 6 3,360 Sep-27-2020, 08:23 PM
Last Post: pythonnewbie138
  Creating a list of RSSI value and send it to the server. Azuan 0 2,687 Jun-08-2020, 11:22 PM
Last Post: Azuan
  Python - change variable type during program execution ple 1 2,440 Apr-12-2020, 08:43 AM
Last Post: buran
  creating a list of dictionaries from API calls AndrewEnglsh101 5 3,163 Apr-03-2020, 02:21 PM
Last Post: AndrewEnglsh101

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020