Question

I want to write a code in phyton that prints only letters from input but skips...

I want to write a code in phyton that prints only letters from input but skips two and prints one.

I want my program to do this;
input = 2ab4c#fd56gjl
output = afj

So it should completely ignore any character other than letters and print the letters by skipping 2.

(Should i use for loop? My classes just beyan so i am guessing the answer code should be a primitive code.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

user = input("Input: ")

letters = ""

for letter in user:
if ord(letter) >= ord('A') and ord(letter) <= ord('Z') or ord(letter) >= ord('a') and ord(letter) <= ord('z'):
letters += letter

result = ""
for i in range(0, len(letters), 3):
result += letters[i]

print ("Output:", result)

Add a comment
Know the answer?
Add Answer to:
I want to write a code in phyton that prints only letters from input but skips...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • 1. Write a python program that reads a file and prints the letters in increasing order...

    1. Write a python program that reads a file and prints the letters in increasing order of frequency. Your program should convert entire input to lower case and only counts letters a-z. Special characters or spaces should not be counted. Each letter and it's occurrences should be listed on a separate line. 2. Test and verify your program and it's output. ---Please provide a code and a screenshot of the code and output. Thank you. ----

  • i need python code, thank you very much! characters) and prints ) 3. Write function, smallestCharacterLargerThan(keyChar,...

    i need python code, thank you very much! characters) and prints ) 3. Write function, smallestCharacterLargerThan(keyChar, inputString) that takes as input key character, keyChar, and a string of one or more letters (and no other the "smallest" character in the string that is larger than keyChar, where one character is smaller than another if it occurs earlier in the alphabet (thus 'C is smaller than 'y' and both are larger than 'B') and 2) the index of the final occurrence...

  • Write a program for IJVM called scramble that takes lowercase text from input and prints the...

    Write a program for IJVM called scramble that takes lowercase text from input and prints the next character (i.e. ‘b’ is printed as ‘c’) and uppercase text and prints the character before (‘B’ is printed as ‘A’). Print all other characters as is.

  • I am trying to write a short program in C that prints the letters that are...

    I am trying to write a short program in C that prints the letters that are the same in two different arrays. I am getting a error. #include <stdio.h> int main() {           char first[7]={'y','a','s','m','i','n','e'};        char last[5]={'s','m','i','t','h'};        int i;                        while(first[i] != '\0') && (last[i] != '\0')        {            if(first[i]==last[i])                 printf("%s", first[i]);                  }         return 0;          }

  • Please write the complete code in C. Write a C function that prints the minimum spanning...

    Please write the complete code in C. Write a C function that prints the minimum spanning tree of a graph. At the end, print the weight of the spanning tree. A suggested report format is shown in the following example. Source Vertex To Vertex Weight A B 2 A C 4 B D 3 D E 1 Total weight of spanning tree: 10 Your main program will read a graph from DataIn file to an adjacency table before calling the...

  • 1. Write a for loop the prints the letter A through Z in reverse. This means...

    1. Write a for loop the prints the letter A through Z in reverse. This means that your output should be Z Y X ... A. It does not matter if all letters are on one line or each on a line by itself. I am looking for the logic.

  • CODE IN C++ 13.5 Alphabet Histogram Write a program that reads input character by character from...

    CODE IN C++ 13.5 Alphabet Histogram Write a program that reads input character by character from the given data file "data.txt" The program should be case insensitive and count the number of occurances of each character in the alphabet. It should print a histogram of the results as follows: A : B : C : * D : * E : * F : G : H : I : J : * K : L : M : N...

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT