If your sprained ankle hurts then it's best to not walk much or at all on the sprained ankle until the pain goes away.
Having pain with the sprained ankle means that the sprained ankle is still healing and if you walk too soon on the sprained ankle it can lead to more injury of the sprained ankle.
Then you may take longer to heal.
So if you're experiencing too much pain with the sprained ankle then avoid walking too much or at all.
If you do need to walk then use some crutches and keep the weight off the ankle that has been sprained until the pain goes away.
If the pain of the sprained ankle gets worse then see a doctor or go to urgent care or the emergency room to get checked out.