Write a program with an input that is a string and a number. Output the first character in the string and then the character that is the number's distance away from the previous character, repeating for the remainder of the string as long as the string is longer than the increment number. Your output wording should match the below examples.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

Python please:

Write a program with an input that is a string and a number. Output the first character in the string and then the character that is the number's distance away from the previous character, repeating for the remainder of the string as long as the string is longer than the increment number. Your output wording should match the below examples.

For example, if the input is

hello 2

the output is

h l o

If the string contains fewer characters than the input number, as in

cat 4

the output is

The integer can't be higher than the string length.

For coding simplicity, output a space after every character, including the last.

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Bare Bones Programming Language
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning