Language:EN
Pages: 2
Words: 182
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
assignment help answers with stepbystep explanatio

Count Consecutive Substrings in Python Assignment Answers

Your question:

student submitted image, transcription available below

Q-2 [30 pts] You need to write a function consecutive(refstring) that takes a string refstring as a parameter and returns the number of disjoint substrings with consecutive characters. A substring with 2 or more consecutive characters will be counted once. For example: consecutive('settle') will return 1 consecutive('printing') will return 0 consecutive('Yessss. Really ? Reaaaaalllly?') will return return 4

Assignment Help Answers with Step-by-Step Explanation:

    for i in range(1, len(refstring)):

        current_char = refstring[i]

        else:

            # Check if the current substring has two or more consecutive characters

    if current_count >= 2:

        count += 1

print(consecutive('Yessss. Really ? Reaaaaalllly?'))  # Output: 4

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Emma Becker PhD

PageId: DOC748341A