2021年4月29日星期四

adding to a string based on the number of characters

the problem says to print "that's a really really ... big number" with one "really" for every extra digit that the number has (so 15 would be "that's a really big number", 150 would be "that's a really really big number", 1500 would be "that's a really really really big number", and so on.)

the input is an integer, and the only requirements listed are that the code should run correctly with any integer, should use a while loop to keep dividing the number by 10 and should use += to add onto the end of a string

x = input(("input an integer: "))  count = len(x)  y = int(x / 10)  countx = count - 1  print("that's a " + count("really") + " big number")  

i don't really know what i did, but i can tell it's not correct

https://stackoverflow.com/questions/67327636/adding-to-a-string-based-on-the-number-of-characters April 30, 2021 at 10:57AM

没有评论:

发表评论