简体   繁体   中英

Python script won't run on the first input

I'm a student and it's only been a few days since I've started python so this question might be really dumb, but my script won't run on the first input. It's supposed to take and integer input and then print it three times on one line( ex : if input is 25, the printed result should be 25 25 25)

As I mentioned before, it's only been so long since I've started to learn python. I'm probably missing something pretty obvious here, so if anyone could please just nudge me in the right direction, that'd be appreciated. :)

if input():
    a = str(input())
    b = int(a,10)
    print('%s %s %s' % (b, b, b))

It's not clear what you are trying to do with your code here, but the line if input() is misusing the input command. See https://www.w3schools.com/python/ref_func_input.asp as this will help clarify how to use it.

I believe the following code will produce what you want

a = input()
b = int(a,10)
if b == 25:
    print('%s %s %s' % (b, b, b))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM