首页 > 解决方案 > 有没有办法在py3的开头打印没有空格?

问题描述

我的输出有问题。我必须打印两个整数的总和。但是输出总是在整数之前带有一个默认的空格。我该如何做对?

'''

i = 4
d = 4.0
s = 'HackerRank '
# Declare second integer, double, and String variables.
# Read and save an integer, double, and String to your variables.
e= int(input(' '))
g= float(input(' '))
h= str(input(' '))
# Print the sum of both integer variables on a new line.

p=i+e
print(p,end='\n')
# Print the sum of the double variables on a new line.
f=d+g
print(f)
# Concatenate and print the String variables on a new line
j= str(s)+str(h)
print(j)
# The 's' variable above should be printed first.

''' 输出:

   6
7.0
HackerRank hi

我该怎么做才能删除整数'6'之前的空格

标签: python-3.x

解决方案


当您进行此更改时,您会清楚地看到它。

e= int(input(' '))
g= float(input(' '))
h= str(input(' '))

改成:

e= int(input('Enter e:'))
g= float(input('Enter g:'))
h= str(input('Enter h:'))

推荐阅读