The Code works right but there is something wrong [duplicate] - python

This question already has answers here:
Why is "None" printed after my function's output?
(7 answers)
Why is this printing 'None' in the output? [duplicate]
(2 answers)
Closed 1 year ago.
This is my code, when I run it gives me the right answer but also it gives me 'None':
My Code:
def art() :
a = input('enter a values')
b = eval(a)
print(b)
print(art())
Output:
enter a values3 + 4
7
None
Does anyone know why is that and how to remove it? Thank you.

Related

When I run this code it prints "none" after normal strings [duplicate]

This question already has answers here:
Why is this printing 'None' in the output? [duplicate]
(2 answers)
Why is "None" printed after my function's output?
(7 answers)
Closed 3 months ago.
When I run this code it has an output of "none"
def typewrite(string):
for i in string:
sys.stdout.write(i)
sys.stdout.flush()
time.sleep(0.04)
username = input(typewrite(f'''
░▒▓▆▅▃▂▁𝐓𝐇𝐄 𝐔𝐍𝐂𝐀𝐍𝐍𝐘▁▂▃▅▆▓▒░
Welcome adventurer, what is your name?
'''))
print(typewrite("Alright hero " + username + " let the adventure begin!"))
screenshot of output
I don't know what to try and I expect it to not have "none"

5*2=55 not 10! Why? [duplicate]

This question already has answers here:
multiplication of two arguments in python [duplicate]
(6 answers)
Getting issue while trying to multiply string and integer [duplicate]
(2 answers)
Closed 3 months ago.
I want to output 5 * 2 = 10 but python output is 55!
How do I resolve this problem?
a = 0
b = 2
a = input("a? :") #(get 5 as input)
c = a * b
print (c)
This is my code.
when I input a number it repeat same number I entered two times insterd of showing multipiy it. What do I have to do to solve this?
a is a string,
so it will be
'5'*2='55'
if you want 10, you need to cast a to int.
a=int(input())
here is the link to document
https://docs.python.org/3/library/functions.html#input

Why the result of “bag” > “apple” is True in Python? [duplicate]

This question already has answers here:
How are strings compared?
(7 answers)
Closed 2 years ago.
Why the result of “bag” > “apple” is True in Python?
I tried this code below i don't know why it show this result and how? Please some one explain it.
print("bag" > "apple")
True
I believe this is True because Python compares the first letter of each word. And b is greater than a in Python.

How to print output in Single line [duplicate]

This question already has answers here:
How can I print multiple things on the same line, one at a time?
(18 answers)
Closed 3 years ago.
I want to know how to print output in a single line
I want to print it like: 1234
instead of
1
2
3
4
Code:
# n = (get in from user)
i=1
while (i<=n):
print (i,)
i +=1
This may help :
For Python 3:
print(i,end='')
For Python 2:
print(i),

How to fix error when adding string to input variables? [duplicate]

This question already has answers here:
How do I append one string to another in Python?
(12 answers)
Closed 3 years ago.
.It says invalid syntax on the ' around the docx.
y = input ("lektion :")
print(y)
document.save(y.'docx')
Use this:
y = input ("lektion :")
print(y)
document.save(y + 'docx')

Categories