❔ Output not as expected. Very beginner, learning ABC of programming.
https://paste.mod.gg/fymahzukuiyz/0
That's the code, It used have shown the output like (111) 222-3334
but its straight up 1112223334, anyone know what I am doing wrong? I might go to sleep so chances that I will reply tomorrow.
BlazeBin - fymahzukuiyz
A tool for sharing your source code with the world!
34 Replies
Pobiega
REPL Result: Success
Console Output
Compile: 448.243ms | Execution: 38.862ms | React with ❌ to remove this embed.
works fine
oh, you treat your number as a string
normally, thats a good idea
but it doesnt work well with number formatting
because its not a number
Oh I see I see, thanks
phone numbers should never be stored as numbers btw
but for the purpose of formatting, its an alternative
I'd probably prefer string slicing thou
What's string slicing?
one sec
Also...I am not sure how to format integers since .format doesn't seem to work with integers like the way I learned it did with strings
look at my example :p
forgot what it was called, function or something, my programming vocabulary is a bit weak rn, I understand stuff in my mind but not know the name. Might need a dictionary xD
im not using string.format
Pobiega
REPL Result: Success
Console Output
Compile: 445.671ms | Execution: 85.733ms | React with ❌ to remove this embed.
thats string slicing
Can you please breakdown how this works logically? My weak memory only allows me to learn that way. What does the $ sign represent specifically since that's the confusing element there.
string interpolation
Pobiega
REPL Result: Success
Console Output
Compile: 589.156ms | Execution: 84.215ms | React with ❌ to remove this embed.
see the difference with and without $?
Ohhh right, seems like easier way to use {0} in a string
yeah, it is
it supports mostly the same format options too
I wonder if it handles string slicing
Pobiega
REPL Result: Success
Console Output
Compile: 554.292ms | Execution: 87.495ms | React with ❌ to remove this embed.
nope
it doesnt like the fact that its a string. so you'll need to slice it up
Let me try slicing it and see if I can get it right that way
I tried this, know what the error is or if I used in a way it wasn't meant to be used?
Actually maybe like this
Hmm but wasn't that like string formatting actually?
you cant "Multislice" the string like htat
Pobiega
REPL Result: Success
Console Output
Compile: 575.709ms | Execution: 84.472ms | React with ❌ to remove this embed.
@Pobiega this works, thanks.
Also you know why did string formatting with numbers for this guy but not in my case?
he is using a number, not a string
just like I did in my example
thats an integer
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.