Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Better than an array
#4
As mentioned earlier my lifetime programming language was Basic.
I ran a test of your suggestion and it gives an error message I have
no idea how to deal with.
Any suggestion most helpful.
tia
oldcity

 #!/usr/bin/python3
 dcatagory = ''
 lcnt = 0
 with open('COL-HDRS-Sel4', 'r') as catgs:
     for lcnt, line in enumerate(catgs, 1) :
         dfiles = line.strip(",")
         dcatagory = dfiles.rstrip("\n")
         mcatg[lcnt] = dcatagory





 catg = 5  # catg value to be assigned later
 print ("\n")
 print(mcatg[catg])
 print("bye ")
 
Code produces this error message.
 @oldcity ~/MyPython $ python3 fix-here
 Traceback (most recent call last):
   File "fix-here", line 8, in <module>
     mcatg[lcnt] = dcatagory
 @oldcity ~/MyPython $ 
Reply


Messages In This Thread
Better than an array - by oldcity - Dec-12-2018, 07:09 PM
RE: Better than an array - by micseydel - Dec-12-2018, 07:10 PM
RE: Better than an array - by wavic - Dec-12-2018, 08:12 PM
RE: Better than an array - by oldcity - Dec-13-2018, 01:01 AM
RE: Better than an array - by ichabod801 - Dec-13-2018, 01:06 AM

Forum Jump:

User Panel Messages

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