My code has a raw_input in it - when I press Enter, it completely ruins the code which says that the string index is out of range. The annoying thing is that if you don't press Enter and type something in, it works perfectly fine.

So my question is - how do you make it so nothing happens if you leave a raw_input blank?

Recommended Answers

All 2 Replies

Do not index string without checking that string exist i.e.

   if my_string:
       # processing string

or use try...except block

Why not post the code and the exception traceback ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.