IN PYTHON. Write a function that ask the user to (a) enter a string, (b) ask the number of time to repeat the string and (c) ask user to input a delimiter to separate them. Call the function and append the test run to your solution. Here is a test run of what is wanted:
Enter a string: Ted
How many repetitions? 10
Separated by? [}(+
Ted[}(+Ted[}(+Ted[}(+Ted[}(+Ted[}(+Ted[}(+Ted[}(+Ted[}(+Ted[}(+Ted
Code:
Note:
If you want the function to return the new string
Remove 'print(new)' statement in the function
Add 'return new' in the function
Raw code:
def separated(): #Function named as separated
string=input("Enter a string: ") #Taking input of main
string
rep=int(input("How many repetitions?")) #Input of num of
repitions
sep=input("Separated by? ") #input of seprated string
new='' #Taking an empty string to form the new required
string
for i in range(rep-1): #loop runs for number of repetitions -1
times
new=new+string+sep #appending main string and seperated by
string
new=new+string #adding the string at last because the loop runs for
one less than the repetations
print(new) #printing the new string
separated() #callling the function
Hope you have understand.if you have any doubts or if you want any modifications ,please comment.
Thank you .Rate my answer.
IN PYTHON. Write a function that ask the user to (a) enter a string, (b) ask...
In python, Write a function that will ask user to enter a number and find if it is odd or even. Example run: Please enter a number: 5 5 is an odd number Please enter a number: 10 10 is an even number
Write a Python program that prompts the user to enter their three favorite bands separate by commas, and prints their selections on three separate bands. Hint: You will need to use the string function, split. A sample run appears below (user input shown in bold): Enter your favorite bands separated by commas: The Beatles,Queen,Bruce Springsteen My favorite bands are: The Beatles Queen Bruce Springsteen
Write a python function that takes in a string to use as a prompt and shows it to the user. Then get input from the user. If they entered a single sign out of the set +,-,*,/,% return it. If they entered anything else, give them a warning: “You may only enter one of the characters: +- * /%” and then repeat until they enter a correct option.
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
3. Write Python statements that will do the following: a) Input a string from the user. *** Print meaningful messages along with your output.* b) Print the length of the String. Example input: The sky is blue. Correct output: The length of the string is 16 Incorrect output: 16 c) Print the first character of the string. d) Print the last character of the string. 4. Save the program. Double-check the left edge for syntax errors or warning symbols before...
Write a Python script in that will prompt the user to enter a string. After the user enters their string print its length and the ordinal value of the first, third, and seventh character. Assume the input will be of sufficient length. Use "nice" input and output
PYTHON Write a function called hourly_employee_input that asks the user for a name (string), hours worked (int) and an hourly pay rate (float) and prints a string including the information. Call the function, entering expected values, numbers in appropriate range Call the function, entering negative numbers Call the function, entering bad input (letters, symbols) What do you need to add to your function for bad input? Handle the bad input so your program doesn't end when receiving bad input
Write a program in python that asks the user to input a sentence. The program will ask the user what two letters are to be counted. You must use a “for” loop to go through the sentence & count how many times the chosen letter appears in the sentence. You are not allowed to use python built-in function "count()" or you'll get a Zero! Output will show the sentence, the letter, and the number of times the letter appears in...
Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...
Write a Python program, with comments, to do the following: Ask the user to enter a string with at least 7 characters. Assume user will enter a valid string. Assign the string to a variable str1 and print str1. In a loop do the following: Update the value of str1 so that the first character from the current value of str1 is removed and added to the end. Print the updated str1. The loop should continue until updated...