I am extremely new to coding so please bear with me.
I am trying to create a loop until a condition is met, namely, an email address. This is what I have so far:
first = input("Please enter your first name: ")
surname = input("Please enter your surname: ")
email = input("Please enter your email address: ")
emailconfirm = input("Please confirm email address: ")
if email != emailconfirm:
input ("Emails are different. Please kindly confirm email address: ")
cell = input("Please enter cell number: ")
How do I code to enter a cell/ mobile number without it printing until the emailconfirm == email condition is met?
I know this may be simple to many but it is VERY early days for me. Many thanks for the assistance.
Graeme
Tried tutorials but I just cannot get it right :(
You need to use a while loop and update the value of emailconfirm in each iteration
email = input("Please enter your email address: ")
emailconfirm = input("Please confirm email address: ")
while email != emailconfirm:
emailconfirm = input("Emails are different. Please kindly confirm email address: ")
i have an array
line_one = ["flinders street", "richmond", "east richmond", "burnley", "hawthorn", "glenferrie"]
user_input1 = "flinders street"
user_input2 = "glenferrie"
how could I count the distance between the two strings?
expected output 5.
The first thing that comes to mind:
line_one = ["flinders street", "richmond", "east richmond", "burnley", "hawthorn", "glenferrie"]
user_input1 = "flinders street"
user_input2 = "glenferrie"
(line_one.find_index(user_input1) - line_one.find_index(user_input2)).abs
#=> 5
line_one = ["flinders street", "richmond", "east richmond", "burnley", "hawthorn", "glenferrie"]
Code
p (line_one.index("flinders street")...line_one.index("glenferrie")).count
output
5
Data I have:
ID
Value
1
[{"code": "SM", "place": "San Mateo, CA, USA"},{"code": "IND", "place": "Indianapolis, IN, USA"}]
What I want it to be transformed as:
ID
Value
1
San Mateo, CA, USA; Indianapolis, IN, USA
This is as far as I can get (table is just a sample)
SELECT
INDEX,
PARSE_JSON(f.THIS),
ARRAY_TO_STRING(PARSE_JSON(f.THIS),';')
FROM TABLE(FLATTEN(input => parse_json('[{"code": "SM","place": "San Mateo, CA, USA"},{"code": "IND","place": "Indianapolis, IN, USA"}]'))) f LIMIT 1;
You're close:
SELECT
seq,
listagg(f.value:place, '; ')
FROM TABLE(FLATTEN(input => parse_json('[{"code": "SM","place": "San Mateo, CA, USA"},{"code": "IND","place": "Indianapolis, IN, USA"}]'))) f
group by seq
-- San Mateo, CA, USA; Indianapolis, IN, USA
I have an array: Array[(String, (Array[String], Int))]
I need to extract:
first element
last element; and 3rd and 4th elements elements of the inside array[Strings]
data from 3 records: I want to display only the bolded items
Array((27120,(Array(27120, 2011-12-01 09:59:17.0, 2013-09-07 08:29:37.0, Dale, Hanson, 2578 Ingram Road, Inglewood, CA,
90309),8)),
(92694,(Array(92694, 2013-01-25 04:11:10.0, 2013-12-04 02:31:35.0, Stacy, Allbritton, 4990 Clearview Drive,
Sacramento, CA, 94215),2))
(40581,(Array(40581, 2012-04-03 17:53:32.0, 2013-12-10 22:46:16.0, Norman, Scanlon, 312 Ocala Street, Sacramento, CA,
95761),2))
)
data should look like:
27120 8 Dale Hanson
92694 2 Stacy Allbritton
40581 2 Norman Scanlon
Thanks!
Given your data in in format, Array[(Int, (Array[String], Int))], you will have to map over the array and extract the information you need.
your data structure looks like
Tuple(integer, Tuple(Array, integer)))
| | | |
| | | |
_1 _2 | |
_2._1 _2._2
example,
scala> val data = Array((27120,(Array("27120", "2011-12-01 09:59:17.0", "2013-09-07 08:29:37.0", "Dale, Hanson", "2578 Ingram Road, Inglewood, CA, 90309"),8)),
(92694,(Array("92694", "2013-01-25 04:11:10.0", "2013-12-04 02:31:35.0", "Stacy, Allbritton", "4990 Clearview Drive, Sacramento, CA, 94215"),2)),
(40581,(Array("40581", "2012-04-03 17:53:32.0", "2013-12-10 22:46:16.0", "Norman, Scanlon", "312 Ocala Street, Sacramento, CA, 95761"),2)))
data: Array[(Int, (Array[String], Int))] = Array((27120,(Array(27120, 2011-12-01 09:59:17.0, 2013-09-07 08:29:37.0, Dale, Hanson, 2578 Ingram Road, Inglewood, CA, 90309),8)), (92694,(Array(92694, 2013-01-25 04:11:10.0, 2013-12-04 02:31:35.0, Stacy, Allbritton, 4990 Clearview Drive, Sacramento, CA, 94215),2)), (40581,(Array(40581, 2012-04-03 17:53:32.0, 2013-12-10 22:46:16.0, Norman, Scanlon, 312 Ocala Street, Sacramento, CA, 95761),2)))
scala> data.map(tuple => (tuple._1, tuple._2._2, tuple._2._1(3)))
res20: Array[(Int, Int, String)] = Array((27120,8,Dale, Hanson), (92694,2,Stacy, Allbritton), (40581,2,Norman, Scanlon))
I want to print data like this :
FirstName FamilyName (33 characters), Tel: xxxxxxxxxx, Age: xx, Level: xx, Salary: xxxxx.xx
For example
John Dilbert Tel: 6135202600, Age: 58, Level: 13, Salary: 450.34
Jane Smith Tel: 6135202600, Age: 47, Level: 10, Salary: 133450.00
Main problem am facing is how to put Tel: one before the other . Also how to format the floating salary such that decimal comes one below the other.
Currently my output look like this :
John Dilbert Tel: 6135202600, Age: 58, Level: 13, Salary: 450.34
Jane Smith Tel: 6135202600, Age: 47, Level: 10, Salary: 133450.00
Code :
void printData(struct person currentPerson){
printf("%s %-33sTel: %10s",currentPerson.firstName,currentPerson.familyName,currentPerson.telephone);
}
void printStudent(struct Student currentStudent){
printf("GPA:%3d, Courses:%3d, Tuition: %5f\n",currentStudent.GPA,currentStudent.coursesCount,currentStudent.tuitionFees);
}
In main:
printData(person[i]);
printf(", ");
printStudent(person[i].student);
But still result is wrong. Why ? Please help
If you want to control the width of your data, then you could use the width sub-specifiers in the printf format string. Eg. :
printf("%5d", 2);