Rantdriven
  • Home
  • Blog
  • Gaming
  • Fashion
  • Business
  • Animations
  • More
    • Write for us
    • About Us
    • Contact Us
    • Editorial Policy
    • Policy of cookies
    • Privacy Policy
    • Terms and Conditions
Rantdriven
Rantdriven
  • Home
  • Blog
  • Gaming
  • Fashion
  • Business
  • Animations
  • More
    • Write for us
    • About Us
    • Contact Us
    • Editorial Policy
    • Policy of cookies
    • Privacy Policy
    • Terms and Conditions
Blog

My Python Program Suddenly Stopped Working: How I Troubleshot the Issue and Resolved it

by Linnea D June 22, 2021
by Linnea D June 22, 2021 0 comment 203 views

I was working on a python program and suddenly it stopped running. I couldn’t figure out why, so I tried to troubleshoot the issue by looking at what the error message said. It told me that there was an attributeerror: ‘list’ object has no attribute ‘split’. This is not helpful because the list variable doesn’t have anything to do with splitting lists in Python! What is happening?

When I looked more closely at the code, it turns out that my list had two elements instead of three. When you write a for loop in Python, if you don’t specify how many items are in the list then only one item will be iterated over each time!

If you don’t want this to happen, then you have to use a range() function and specify how many items there are in the list. For example, for i in range(0,len(mylist),i): means that the code will loop over each item of mylist so I can extract any information from it! Another option is if you would like your list split into chunks instead:

This splits up my list every hundred elements. I’ll divide them by ten because we’re only interested in specific sections of the array. That way they won’t take as long to compute or execute. Like with previous examples though, always remember to specify the length of the list, or else your code will be incorrect

To know if my program was working I had to troubleshoot it. My Python script suddenly stopped working and when I tried running it in a different IDE such as PyCharm or Anaconda Spyder there were no errors so that meant that either something with my system changed on its own, which would’ve been very unlikely because nothing happened out of the ordinary before this event occurred, or it’s an issue with handling data types. Data type is just another way of saying how items in a list are being stored internally by our computer like integers vs strings (text). It can get confusing but luckily for me, since I am using Python version three (aka v.three) I know the list data type is a mutable data type. Mutable means that it changes its state during runtime, which was my first clue to troubleshooting what happened.

I checked in Windows Task Manager and saw an increase in CPU usage for Python interpreter process (which meant there were more system resources being used by this program) so I knew something was going on but couldn’t tell if it’s affecting other programs since all of them are running at the same time when you’re using your computer. The next thing I did was look up errors messages generated from error logs and see if any matched the one thrown by my code: attributeerror: ‘list’ object has no attribute ‘split’. This actually gave me precise information about what was happening.

I have seen this error before when I’m working with lists in Python and forgot to add the ‘split’ attribute, which is required for splitting a list into smaller chunks. So that’s why my program stopped working! The fix? Adding it of course 🙂

pe is a mutable data type; mutable means that it changes its state during runtime, which was my first clue to troubleshooting what happened – In Windows Task Manager, there were more system resources being used by the Python interpreter process so I knew something was going on but couldn’t tell if it’s affecting other programs since all of them are running at the same time when you’re using your computer

The next thing I did was to search for the problem online

I found a couple of people who had this error and one said to delete all files in C:\Python27\Lib, which is where Python stores stuff like modules. So that’s what I did

After doing it, my program was back working as expected!

I have seen this error before when I’m working with lists in Python and forgot to add the ‘split’ attribute, which is required for splitting a list into smaller chunks. So that’s why my program stopped working! The fix? Adding it of course 🙂 – pe is a mutable data type; mutable means that it changes its state during runtime, which was my first clue to troubleshooting what happened – In this case, my program wasn’t able to ‘split’ the list because it didn’t have that attribute. I found this by adding an empty string at the end of the list and then running split() on it – The last thing is to make sure you do a clean-up after your troubleshooting efforts

The next thing I did was search for what could be wrong online (I left out numbers from now on)

After looking through some threads about people with similar problems as me, one person said they fixed their issue deleting all files in C:\Python27\Lib; so that’s exactly what I went ahead and did! After doing this, my Python script started working again just fine.

Share
0
FacebookTwitterPinterestEmail
Linnea D

I am a blogger who loves to write and read blogs. I specialize in all types of posts, including social media support.

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

Popular Posts

  • powered by emeeting

    March 1, 2022
  • powered by emeeting

    March 1, 2022
  • powered by emeeting

    March 1, 2022
  • 4

    Stand Out in the Crowd: Open Shoulder Top

    June 19, 2021
  • 5

    Reviews and Ratings of Angie’s List in San Diego

    June 22, 2021
  • Facebook
  • Twitter
  • Instagram
  • Pinterest
  • Home
  • About Us
  • Contact Us
  • Terms and Conditions
  • Privacy Policy

@2021 - All Right Reserved. Rantdriven

Rantdriven
  • News
  • Business
  • Gaming
  • Movie
  • Technology
  • More
    • About Us
    • Contact Us
    • Terms and Conditions
  • Write for us
@2021 - All Right Reserved. Rantdriven

Read alsox

peoplesoft consulting companies

July 1, 2022

tribe community

November 12, 2021

smile io vs yotpo

August 23, 2021