Python Forum
What would be a substitute for "::" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: What would be a substitute for "::" (/thread-30181.html)



What would be a substitute for "::" - hhydration - Oct-10-2020

The use of :: is prohibited for certain assignments, what would be a substitute that would allow you to do things like print every other character in a string?


RE: What would be a substitute for "::" - scidam - Oct-10-2020

If slicing is allowed for the object,  you can use it directly, e.g.:

'a string'[slice(None, None, 2)]