• Register
1 vote
39 views

Problem:

I am a python newbee. I was trying to  print string and int on same line of a python code. The code I wrote is:

a = int(input("Please Enter a Number: "))
print("Your Number is" a)

but when I run this it shows an error message:

File "main.py", line 2
    print("Your Number is" x)
                           ^
SyntaxError: invalid syntax

I am not able to do this please help me to solve this problem?

10 7 2
6,060 points

1 Answer

1 vote

Answer:

You sould put a comma(,) before your a to get no errors. So write your code like:

a = int(input("Please Enter a Number: "))

print("The number is", a)

And yo will get an output like:

Please Enter a Number: 12
The number is 12

or you can also write your code like:

a = int(input("Please Enter a Number: "))

print("The number is " + str(a))

Happy coding.

11 6 4
34,950 points

Related questions

0 votes
1 answer 5 views
5 views asked 5 days ago Shaad Sh 800 points
1 vote
1 answer 37 views
37 views
Problem: Being a newbie in C++ programming, I wonder if I can concatenate an integer type and a string together! As I can concatenate two string, in the same way, is it possible to concatenate two different data types? I am in a certain condition right now and I ... ; and the integer is “7” I want to bind them together and display it as: Bond7 Thanks, guys. I appreciate your concern.
asked May 19 adamSw 11.3k points
0 votes
1 answer 8 views
0 votes
1 answer 6 views
6 views asked Oct 16 SapperIt 1.2k points
1 vote
1 answer 26 views
26 views
Problem: I am beginner in pyhton prgramming language, I tried to convert string array to int array using python so I wrote a code which contains- testing_list = ['4', '2', '3', '9', '5'] And my code is: testing_list = ['4', '2', '3', '9', '5 ... list is : str(testing_list) Converted list is : str(testing_list) why am I not getting the converted result and what is the way to get the acurate result?
asked Mar 29 LizzyM 6.1k points