Assigning String and Integer to Variable

Click For Summary
SUMMARY

The discussion focuses on assigning a combined string and integer to a variable in programming. The user, arokum, seeks to concatenate a fixed string "Sym_" with an integer variable n, specifically using the syntax n:=10. The output "Sym_10" needs to be assigned to another variable. Arokum mentions that while the "Print()" command outputs the desired result, it does not directly assign values to variables. The alternative suggested is using "JoinStringsWithSeparator(list,[])", which, although functional, is not preferred.

PREREQUISITES
  • Understanding of variable assignment in programming languages
  • Familiarity with string manipulation techniques
  • Knowledge of the "Print()" function and its limitations
  • Experience with the "JoinStringsWithSeparator()" function
NEXT STEPS
  • Research how to use string interpolation in programming languages
  • Learn about variable concatenation methods in your specific programming language
  • Explore the use of the "sprintf()" function for formatted strings
  • Investigate alternative string manipulation libraries or functions
USEFUL FOR

This discussion is beneficial for programmers and developers who need to understand variable assignment and string manipulation techniques in their coding practices.

arokum
Messages
2
Reaction score
0
Hi everyone,

I'm trying to assign a string in combination with an integer to a variable v. The string-part is fix, the integers comes from another variable n. For Example:

Code:
n:=10;
Print("Sym_",n);

The output of "Print(...);" (that is "Sym_10") should be assigned to another variable. Does anyone know how to do that? There doesn't seem to be a functionality analogue to the "Print()" command when it comes to assigning values to variables. Or can I use "Print()" in some way to solve my problem?

Thanks in advance.

Kind regards,
arokum
 
Physics news on Phys.org
Hello again,

Using "JoinStringsWithSeparator(list,[])" is no nice solution, though it works.

Kind regards,
arokum
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
Replies
1
Views
920
  • · Replies 5 ·
Replies
5
Views
2K
Replies
1
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K