Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So I’m not sure how I can fix this because but I can’t figure it out this is ProjectSTEM 1.6 question 1 and I can’t pass test 2 which says this “ This test case checks that your program uses input commands to determine the output phrase. This test case also checks the syntax of your final output phrase.
Check that your program uses input statements, and that your final output statement is formatted correctly.” Here is the code I have written down

My code:
word1 = input("Enter a word: ")
word2 = input("Enter a word:")
print(word1 + word2)
The sample I’ve been given:
Enter a word: Hello
Enter a word: World
Hello World

What I have tried:

I’ve tried rewriting the code entirely, reading instruction over and over again asking my teacher
Updated 11-Oct-22 16:57pm
Member 8428760 11-Oct-22 20:23pm    
This is an annoying detail, but try print(word1 + " " + word2). There has to be a space between them.

1 solution

You can add space between two strings in various ways.
Few being:

1. Using .format
print("{} {}".format(item1, item2))

2. Using default of print. Default is to add space between arguments.
print(item1, item2)

3. Using .join
print(" ".join([item1, item2]))

4. Using string representation
print("%s %s" % (item1, item2))

Not suggesting the string concatenation using a + and space as least preferred way.

print(word1, word2) #OR
print("{} {}".format(word1, word2))
# Output
# Enter a word: Hello
# Enter a word: World
# Hello World
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900