I have to print every third letter of the text with spaces between them and not a single one at the end. I can do everything except spaces between each letter.
Here is what I have.
line = input('Message? ') print(line[0]+line[3::3].strip())
To combine things with spaces, use join(). Consider the following:
join()
>>> line = '0123456789' >>> ' '.join(line[::3]) '0 3 6 9'
Python 3, * print(), . line[0] - ([0::3]), ([::3]). , strip(), , Enter, input().
*
print()
line[0]
[0::3]
[::3]
strip()
input()
print(*input('Message? ')[::3])
Source: https://habr.com/ru/post/1613925/More articles:Logging, exiting, and exceptions for methods in Java using aspects - javaOptional parameter with UML class diagram - umlHow to use a function recursively? - cHow to make #if #endif part of a macro - cCypher: how to map relationships - node - relation inside the path - neo4j/ usr / bin / ld: cannot find -lGL (Ubuntu 14.04) - c ++Why can't I ping addresses with leading or trailing underscores on linux - linuxHow to write automatic documentation for gulp tasks? - javascriptHow to express inequality in the prologue? - prologHow to remove a diagonal square element from a matrix? - matrixAll Articles