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?
#3
Thank you all for your replies.
I have tried the below:-
This is a section from the question instruction:-
"#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."

Below is what I entered into the Python IDLE on my desktop and got the correct response:-

[b]mystery_string = "ABCDE"
mystery_string = input("please enter a variable:  ")
print((mystery_string+".")*3+"???")[/b]
please neter the variable: ABCDE
ABCDE.ABCDE.ABCDE.???

>>>

please neter the variable: VWXYZ
VWXYZ.VWXYZ.VWXYZ.???

>>>

I put the same into the test environment:-

[b]mystery_string = "ABCDE"
mystery_string = input("please enter a variable:  ")
print((mystery_string+".")*3+"???")[/b]
We tested your code with mystery_string = "VWXYZ". We expected your code to print this:

VWXYZ.VWXYZ.VWXYZ.???

However, it printed this:

EOFError: EOF when reading a line



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

ZSYNP.ZSYNP.ZSYNP.???

However, it printed this:

EOFError: EOF when reading a line
Reply


Messages In This Thread
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