OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

TypeError: can only concatenate str (not "list") to str. what?

  • Thread starter Thread starter Ash
  • Start date Start date
A

Ash

Guest
the code I'm writing needs to be a string, but i used a list to complete the code.

idk how to fix it.

Code:
lists = []
def int_to_reverse_binary(number):
    
    while number >= 1:
        lists.append(int(number % 2))
        number = number / 2
        
    else:
        return lists
        
def string_reverse(user_input):
    for num in reversed(lists):
        print(num, end='')
    return print()
    

if __name__ == '__main__':
    input = int(input())
    
    a = (int_to_reverse_binary(input))
    
    string_reverse(a)
<p>the code I'm writing needs to be a string, but i used a list to complete the code.</p>
<p>idk how to fix it.</p>
<pre class="lang-py prettyprint-override"><code>lists = []
def int_to_reverse_binary(number):

while number >= 1:
lists.append(int(number % 2))
number = number / 2

else:
return lists

def string_reverse(user_input):
for num in reversed(lists):
print(num, end='')
return print()


if __name__ == '__main__':
input = int(input())

a = (int_to_reverse_binary(input))

string_reverse(a)
</code></pre>
 

Latest posts

Top