Question

I need help with this python programming assignment

For this task youre going to write a function that joins strings from a list. The function called join ) has one formal para

please double check the indentations

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

PYTHON PROGRAM:

def join(lst,sep=' '):
accumulator=''
if len(lst)==1:
accumulator=lst[0]
return accumulator
else:
for i in range(1,len(lst)-1):
accumulator=accumulator+sep+lst[i]
accumulator=lst[0]+accumulator+sep+lst[-1]
return accumulator

title=['Spider-Man:','Into','The','Spider-Verse']
print(join(title))
print(join(title,sep=''))
print(join(title,sep='-*-'))
print()
name=['Insteller']
print(join(name))
print(join(name,sep="-*-"))
print()
title=['Love','is','in','the','air']
print(join(title))
print(join(title,sep=''))
print(join(title,sep='-*-'))

INDENTATIONS:

def join(1st,sep- accumulator- if len(1st)--1: accumulator-lst[e] return accumulator for i in range (1,len(1st)-1): accumula

OUTPUT:

Spider-Man: Into The Spider-Verse Spider-Man: IntoTheSpider-Verse Spider-Man: -*-Into-*-The-*-Spider-Verse Insteller Instelle

Add a comment
Know the answer?
Add Answer to:
For this task you're going to write a function that joins strings from a list. The function calle...
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
  • solve with python Write a recursive function recStringWithLenCount() that takes a one-dimensional list of strings as...

    solve with python Write a recursive function recStringWithLenCount() that takes a one-dimensional list of strings as a parameter and returns the count of strings that have at least the length of second parameter passed into the function that are found in the list. Recall that you can determine whether an item is a string by writing type(item) == str. The only list functions you are allowed to use are len(), indexing (lst[i] for an integer i), or slicing (lst[i:j] for...

  • HW7.26. Return a CSV string from a list of numbers The function below takes a single...

    HW7.26. Return a CSV string from a list of numbers The function below takes a single parameter, a list of numbers called number_list. Complete the function to return a string of the provided numbers as a series of comma separate values (CSV). For example, if the function was provided the argument [22, 33, 44], the function should return '22,33,44'. Hint: in order to use the join function you need to first convert the numbers into strings, which you can do...

  • Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings...

    Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings as a parameter. The strings are intended to represent a person's first and last name (with a blank in between). Assume the last names are unique. The function should return a dictionary (dict) whose keys are the people's last names, and whose values are their first names. For example: >>> dictionary = names([ 'Ljubomir Perkovic', \ 'Amber Settle', 'Steve Jost']) >>> dictionary['Settle'] 'Amber' >>>...

  • Hello can anyone help solve this please in Python the way it's asked? Question 22 40 pts List Comprehensions Write...

    Hello can anyone help solve this please in Python the way it's asked? Question 22 40 pts List Comprehensions Write the solution to a file named p2.py and upload it here. Comprehensions will show up at the midterm exam, so it's important to practice. a) Write a list comprehension that returns a list [0, 1,4, 9, 16, .. 625] starting from range(0, 26). (lots of list elements were omitted in ...) b) Write a list comprehension that returns the list...

  • C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the r...

    C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the required information. Your function should return the number of student entries read from the file. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1 and do not print anything.     Your function should be named...

  • Help needed related python task ! Thanx again How you're doing it • Write a function...

    Help needed related python task ! Thanx again How you're doing it • Write a function write_to_file() that accepts a tuple to be added to the end of a file o Open the file for appending (name your file 'student_info.txt') o Write the tuple on one line (include any newline characters necessary) o Close the file • Write a function get_student_info() that o Accepts an argument for a student name o Prompts the user to input as many test scores...

  • Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a...

    Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...

  • In PYTHON! Exercise 3: Lists and Functions In this exercise we will explore the use of...

    In PYTHON! Exercise 3: Lists and Functions In this exercise we will explore the use of lists and functions with multiple inputs and multiple outputs. Your task is to implement the separate_and_sort function. This function takes two input parameters: 1. A list containing strings and integers in any order. 2. An optional integer parameter size which controls how many items in the list the function will process. If the length of the list is smaller than the value of size,...

  • a) Declare and instantiate an array named scores of twenty-five elements of type int.   (b)Write a...

    a) Declare and instantiate an array named scores of twenty-five elements of type int.   (b)Write a statement that declares an array namedstreetAddress that contains exactly eighty elements of typechar. 2. In a single statement: declare, create and initialize an arraynamed a of ten elements of type int with the values of the elements (starting with the first) set to 10, 20,..., 100 respectively. 3. Declare an array reference variable, week, and initialize it to an array containing the strings "mon",...

  • Write a program that uses a recursive function to determine whether a string is a character-unit...

    Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example "A nut for a jar of tuna" is a palindrome if spaces are ignored and not otherwise. "Step on no pets" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences...

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
ADVERTISEMENT