Python Forum

Full Version: problem a with a word question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am stumped solving this question, does anyone have a solution? Huh
prefix = "Sir"
first = "Reginald"
last = "Poofter"
suffix = "III"
What's the question?
(May-25-2018, 09:25 PM)micseydel Wrote: [ -> ]What's the question?
Output:
The question is to use word parts to make 2 correct answers. A example is shown above.
"above"?

Please take a careful look at both of your threads. We want to help. But there is a minimum contribution we need from you - not because of any arbitrary rules, but because we literally don't have enough information to do so. You need to look at your threads and consider, "Is there enough information here for someone to help me with this?"
Fancy names

Use a multiple assignment to add the prefix before the given first name and the suffix after the given last name, then print the full name. The string value in first should include the prefix, and the string value in last should include the suffix.

Remember
Add spaces between the words!

prefix = "Sir"
first = "Reginald"
last = "Poofter"
suffix = "III"

1

print ("Sir Reginald Poofter III")

2

prefix = "Mr"

3

first = "Maxmilian"

4

last = "Archibaldus"

5

suffix = "Sr"

6

print ("Mr Maxilian Archibaldus Sr")

7



Expected output
Sir Reginald Poofter III
(May-27-2018, 02:01 PM)baobei Wrote: [ -> ]Use a multiple assignment to add the prefix before the given first name and the suffix after the given last name, then print the full name. The string value in first should include the prefix, and the string value in last should include the suffix.

Remember
Add spaces between the words!

Hi!

You could use something like:

import random

print(f"These are some possible random names:\n")
for x in range (25):
    prefix = random.choice(['Sir', 'Mr', 'Dr', 'Lord', 'Captain'])
    first = random.choice(['Alexis', 'Ashley', 'Casey', 'Jordan', 'Taylor'])
    last = random.choice(['Smith', 'Jones', 'Davies', 'Evans', 'Wilson'])
    suffix = random.choice(['Sr', 'Jr', 'II', 'III', 'IV'])
    print(f"{prefix} {first} {last} {suffix}.")
and that produces random names outputs like the following one:
Output:
These are some possible random names: Captain Jordan Wilson Sr. Dr Taylor Davies III. Captain Ashley Evans Jr. Dr Ashley Davies III. Captain Ashley Wilson Jr. Dr Jordan Davies IV. Captain Alexis Evans Jr. Sir Alexis Jones II. Dr Casey Jones Jr. Dr Jordan Jones III. Dr Ashley Davies Sr. Dr Ashley Davies II. Sir Ashley Wilson Jr. Mr Jordan Wilson Sr. Captain Jordan Davies Sr. Captain Taylor Jones Jr. Captain Casey Smith IV. Dr Casey Evans Sr. Lord Ashley Evans II. Mr Ashley Davies IV. Sir Alexis Smith Jr. Captain Taylor Wilson III. Mr Ashley Davies II. Captain Taylor Smith Sr. Dr Taylor Davies IV. >>>
All the best,