How to use for loops and assign values to array
x = 3 z = IncreasingArrays() z = x.binary()
for i in range(x): if z[i] == 1: print(' ', 2^i) # Not printing here
I'm unable to print the 3rd line it always says space indent etc.
How to solve this? Also please help me how to assign values in an array in for loop
Also binary values I should store in array how to??
I'm new please help
I'm using this only on sagemath cell server online
Thanks
Could you please provide your code ? To format it, you select the code and click on the 101011 button on top of the edition box.
Thanks for the response
x=3 z=IncreasingArrays() z=x.binary()
for i in range(x): if(z[i]==1): print (' ',2^i) #Not printing here
I want to print if binary value is 1 And raise it to power 2
For loop isn't printing print statement also Please help me with these for loops and also how to store values in an array
in C I go
int a[6]; for(i=2;i<=5;i++) { a[i]=1; }
Here like this in C, array values are set.
How to do the same in sage please help
Still no indentation. We can't help you without it : In Python, whitespace (indentation, line feeds) is syntactic.
Now please check again I have written the program.
Also how to initiate elements in array, please tell me