Python Forum
please help with this question about using operators to multiply a string?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
please help with this question about using operators to multiply a string?
#1
mystery_string = "ABCDE"

#You may modify the lines of code above, but don't move them!
#When you Submit your code, we'll change these lines to
#assign different values to the variables.

#In the example above, we saw using operators to add
#characters to the end of a string, and using operators to
#multiply a string.
#
#Add some code below that uses those operators to modify
#mystery_string such that its value at the end of the
#program is: ABCDE.ABCDE.ABCDE.??? Then, print the final
#value of mystery_string.
#
#You should not create any new strings longer than one
#character. We'll test your code with a couple other
#variants on mystery_string, but in all cases the results
#should be the same: the string repeated three times with
#a period after each repetition and three question marks
#at the end.


#Add your code here!
print(("ABCDE." * 3) + "???")

#the above is what I put in.
#below is the answer i am getting and am confused as to why my code is wrong.
#[Executed at: Tue Feb 26 9:02:19 PST 2019]

We found a few things wrong with your code. The first one is shown below, and the rest can be found in full_results.txt in the dropdown in the top left:

We tested your code with mystery_string = "VWXYZ". We expected your code to print this:

VWXYZ.VWXYZ.VWXYZ.???

However, it printed this:

ABCDE.ABCDE.ABCDE.???
My result was correct as far as I can see, but am getting queries regarding other "variables"
Don't understand whats wrong with it. Or don't understand the question in the first place. Please help.
Reply


Messages In This Thread
please help with this question about using operators to multiply a string? - by GilesTwigg - Feb-26-2019, 05:36 PM
RE: please help with this question - by ichabod801 - Feb-26-2019, 05:46 PM
RE: please help with this question - by GilesTwigg - Feb-27-2019, 11:45 AM
RE: please help with this question - by ichabod801 - Feb-27-2019, 04:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use of if - and operators Pedro_Castillo 1 601 Oct-24-2023, 08:33 AM
Last Post: deanhystad
  String to List question help James_Thomas 6 1,222 Sep-06-2023, 02:32 PM
Last Post: deanhystad
  syntax error question - string mgallotti 5 1,539 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Mixing Boolean and comparison operators Mark17 3 1,538 Jul-11-2022, 02:20 AM
Last Post: perfringo
Big Grin General programming question (input string)[ jamie_01 2 1,732 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Question about change hex string to integer sting in the list (python 2.7) lzfneu 1 2,650 May-24-2021, 08:48 AM
Last Post: bowlofred
  Question on HTML formatting with set string in message Cknutson575 3 3,654 Mar-09-2021, 08:11 AM
Last Post: Cknutson575
  Magic Method Arithmetic Operators ClownPrinceOfCrime 3 2,444 Jan-10-2021, 03:24 PM
Last Post: ndc85430
  Class and Operators in Python rsherry8 1 2,071 May-27-2020, 07:09 PM
Last Post: buran
  question: finding multiple strings within string djf123 4 3,130 May-16-2020, 01:00 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020