Home > other >  Beginners ask how python in to variable assignment branch assignment thank you
Beginners ask how python in to variable assignment branch assignment thank you

Time:11-17

The following code, for example,
A="ABC"
B="sda"
C="sdas"
Matrix=(a + '\ n' + '\ n' + b + b)
Want to make the matrix the variable itself into a
Matrix=ABC
Sda
Sdas
Like this is how to assign a value to the effect of?
With \ n words directly to view the value of the matrix is shown on the graph effect
Only the print out is the branch,
Baidu along while didn't find the right solution, has said direct branch, also have said with "" "but these are all the print on the inside of the three quotes to work writing,

A="ABC"
B="sda"
C="sdas"
Matrix=(a + '\ n' + '\ n' + b + b)

CodePudding user response:

You the purpose of this assignment is not very good. What is the value of the variable shape has nothing to do with the calculation results, if convenience to watch, can use the "" "" "" if in order to calculate, can use a list, etc.,

CodePudding user response:

Indeed, assignment shape and calculation result has nothing to do, we usually pay more attention to the output

CodePudding user response:

 a="a b c \ \ na na b c b c" 
Print (a)
# result:
# a b c
# a b c
# a b c

CodePudding user response:

Thank you very much! Purpose because I met a topic need to use a for loop output multiple branches are arranged like this I string (according to every time I change the string on the inside of a few characters),
If can one-time assignment to a variable might be a bit easy for me a new purpose (because the only think of this solution),
So want to bother with bosses solve, this request could not be achieved like me?

CodePudding user response:

reference qq_45883336 reply: 3/f
 a="a, b, c \ \ na na b c b c" 
Print (a)
# result:
# a b c
# a b c
# a b c

Print the branch I understand, but if you want to make itself a
A b c
A b c
A b c
Is there any way to this form. Thank you!
  • Related