Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:01:53+00:00 2026-06-13T23:01:53+00:00

def punctuation(x,y): if len(x) == 0: return y if ‘.’ in x[0]: x[1] =

  • 0
def punctuation(x,y):
 if len(x) == 0:
     return y

 if '.' in x[0]:
     x[1] = x[1].capitalize()
     return punctuation(x[1:],y.append(x[0]))
 elif '!' in x[0]:
     x[1] = x[1].capitalize()
     return punctuation(x[1:],y.append(x[0]))
 elif '?' in x[0]:
     x[1] = x[1].capitalize()
     return punctuation(x[1:],y.append(x[1]))
 else:
     return punctuation(x[1:],x[0])


 z = ['!a','b'] 
 punctuation(z,[])

Hope to get [‘!a’,’b’] ,which means if the first item contains (!,?,.),the second one become capitalize

Q3_p1 = "Enter the digit on the phone (0-9): "
Q3_p2 = "Enter the number of key presses (>0): "



def enter_msg(n):
    x=raw_input(Q3_p1)
    y=raw_input(Q3_p1)
    Jay = Jay_chou(x,y)
    return Jay

 def Jay_chou(d,n):

     if d==0: return " " 
     elif d==1: return [".", ",", "?"][n%3-1]
     elif d==2: return ["a", "b", "c"][n%3-1]
     elif d==3: return ["d", "e", "f"][n%3-1]
     elif d==4: return ["g", "h", "i"][n%3-1]
     elif d==5: return ["j", "k", "l"][n%3-1]
     elif d==6: return ["m", "n", "o"][n%3-1]
     elif d==7: return ["p", "q", "r", "s"][n%4-1]
     elif d==8: return ["t", "u", "v"][n%3-1]
     else: return ["w", "x", "y", "z"][n%4-1]


 enter_msg(2)

i don’t know why i got the error
i see this:

Enter the digit on the phone (0-9): 1

Enter the digit on the phone (0-9): 1

['1', '1']

TypeError: not all arguments converted during string formatting
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:01:54+00:00Added an answer on June 13, 2026 at 11:01 pm

    For the second probelm:

    you’re passing strings to Jay_Chou() in Jay = Jay_chou(x,y), instead you should pass integers. In your case the n%3 part actually tries to do string formatting instead of modulus operation.

    raw_input() returns strings, you need to convert them to integers using int()

    so you get this error:

    In [13]: '1'%3
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-13-39edc619f812> in <module>()
    ----> 1 '1'%3
    
    TypeError: not all arguments converted during string formatting
    

    try this:

    Jay = Jay_chou(int(x),int(y))

    then it outputs:

    Enter the digit on the phone (0-9): 3
    Enter the digit on the phone (0-9): 4
    d
    
    #and for 1,1:
    
    Enter the digit on the phone (0-9): 1
    Enter the digit on the phone (0-9): 1
    .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def download_if_dne(href, filename): if os.path.isfile(filename): # print 'already downloaded:', href return False else: if
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
def common_elements(list1, list2): Return a list containing the elements which are in both list1
def getStuff(x): return 'stuff'+x def getData(x): return 'data'+x thefunctions = [] thefunctions.append(getStuff) thefunctions.append(getData) for
def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails
def any? if block_given? method_missing(:any?) { |*block_args| yield(*block_args) } else !empty? end end In
def record return unless @supported klasses = profile_options[:formats].map { |f| RubyProf.const_get(#{f.to_s.camelize}Printer) }.compact klasses.each do
def filter(f, lst): if lst == []: return [] if f(lst[0]): return [lst[0]] +
def remove_section(alist, start, end): Return a copy of alist removing the section from start
def function(message): if 'START' in message: timer = 10 #start a thread which sleeps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.