Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
import strconv
|
||||
|
||||
fn main() {
|
||||
mut n, mut value, mut i := 0, 0, 1
|
||||
mut name :=""
|
||||
mut vars := map[string]int{}
|
||||
for n < 1 || n > 5 {
|
||||
n = strconv.atoi(os.input("Integer variables (max 5): ")) or {println("Invalid input!") continue}
|
||||
}
|
||||
for i <= n {
|
||||
println("OK, enter the variable names and their values, below:")
|
||||
println("Variable ${i}")
|
||||
name = os.input_opt(" Name: ") or {println("Invalid input!") exit(1)}
|
||||
for {
|
||||
value = strconv.atoi(os.input(" Value: ")) or {println("Must by a number!") continue}
|
||||
break
|
||||
}
|
||||
vars[name] += value
|
||||
i++
|
||||
}
|
||||
println("\n" + "Enter q to quit")
|
||||
for {
|
||||
name = os.input_opt("Which variable do you want to inspect: ") or {println("Invalid input!") exit(1)}
|
||||
if name.to_lower() == "q" {break}
|
||||
if name !in vars {println("Sorry there's no variable of that name, try again!")}
|
||||
else {println("Its value is ${vars[name]}")}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue