68.0k views
3 votes
Write the code to prompt the User for website name and a domain name. Display the website name, then add "www." to the beginning of it and "." to the end of it, where is the domain name they entered (e.g. "com", "edu", "net", etc.) . Display the resultant String. Write the code to prompt the User for website name and a domain name. Display the website name, then add "www." to the beginning of it and "." to the end of it, where is the domain name they entered (e.g. "com", "edu", "net", etc.) . If the user included the "." (dot) in the , do not add an additional dot. If they did not include the dot, then add the dot to the resultant String. Display the resultant String.

1 Answer

5 votes

Final answer:

To prompt the user for a website name and a domain name in Python and display the resultant string with the required format, you can use the input() function and string concatenation. Add 'www.' to the beginning of the website name and a dot to the end of the domain name, if necessary.

Step-by-step explanation:

To prompt the user for a website name and a domain name, you can use the input() function in Python. Here's an example code that accomplishes the task:



website_name = input("Enter the website name: ")
domain_name = input("Enter the domain name: ")

if '.' in domain_name:
website = f'www.{website_name}.{domain_name}'
else:
website = f'www.{website_name}.{domain_name}.'

print(website)



This code first prompts the user to enter the website name and domain name. Then it checks if the domain name already includes a dot. If it does, it concatenates 'www.' before the website name and the domain name. If it doesn't, it adds an additional dot before the domain name.

User Matt Denwood
by
9.0k points

No related questions found