-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvariable_name.py
More file actions
43 lines (25 loc) · 874 Bytes
/
Copy pathvariable_name.py
File metadata and controls
43 lines (25 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def solution(name):
return name.isidentifier()
print(solution('var_1__Int'))
# Expected Output: true
print(solution('variable0'))
# Expected Output: true
print(solution('2w2'))
# Expected Output: false
# Correct variable names consist only of English letters,
# digits and underscores and they can't start with a digit.
# Check if the given string is a correct variable name.
# Example
# For name = "var_1__Int", the output should be
# solution(name) = true;
# For name = "qq-q", the output should be
# solution(name) = false;
# For name = "2w2", the output should be
# solution(name) = false.
# Input/Output
# [execution time limit] 4 seconds (py3)
# [input] string name
# Guaranteed constraints:
# 1 ≤ name.length ≤ 10.
# [output] boolean
# true if name is a correct variable name, false otherwise.