0

I am translating code from c ++ to python, I met with such a data type:

bool b[110];

How can this be translated into Python? I tried to do something, but in my opinion something is wrong here.

b = [False] * (110)
4
  • What is wrong with your code? Please remember that in Python, you don't need to pre-allocate data structures like lists. Commented Dec 18, 2022 at 21:11
  • What is your expected end result? Commented Dec 18, 2022 at 21:13
  • When I execute a function in c++, array b looks like this: 1110x55674af1c1a0, but in Python: [True, False, False,.....,False] Commented Dec 18, 2022 at 21:16
  • Do you need the Python code to be undefined behavior compatible with the C++ code? Commented Dec 18, 2022 at 22:51

1 Answer 1

1

I don't really see a difference between bool b[110]; and b = [False] * 110. Besides that bool b[110]; only does "Garbage initialization" and python doesn't have anything even remotely similar to that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.