wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
y > 34 & a < 87 | y > 34 and a < 87 | Use 'and' not '&'. | Python |
{{"value":"info" "name":62}} | {{"value":"info", "name":62}} | Add comma. | JSON |
local c = 88 | local c = 88 | Correct. | Lua |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
[94, 66, 3 | [94, 66, 3] | Close bracket. | Python |
for (index in items) | for (index of items) | for...in iterates keys. | JavaScript |
if ($c = 41) | if ($c == 41) | Use ==. | Perl |
assert x > 6 | assert x > 6 | Correct. | Python |
if (foo = 54) | if (foo == 54) | Use ==. | R |
temp = 48 | temp=48 | No spaces. | Shell |
name: data
age: 20 | name: data
age: 20 | Correct. | YAML |
INSERT INTO users VALUES ('result',98) | INSERT INTO users (name, email) VALUES ('result',98); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
yield temp | yield temp | Correct yield. | Python |
print('world') | print('world') | Correct. | R |
let z: number = 'hello'; | let z: string = 'hello'; | Fix type. | TypeScript |
let str = String::from("world"); let borrow=&str; str.push_str("!"); | let mut str = String::from("world"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<entry><name>hello</name><age>29</age></entry | <entry><name>hello</name><age>29</age></entry> | Add closing >. | XML |
fn test() -> i32 {{ 30 }} | fn test() -> i32 {{ 30 }} | Correct. | Rust |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
class User {{ int data; }}
obj.data=5; | class User {{ public int data; }}
obj.data=5; | Make field public. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
disp('data') | disp('data') | Correct. | MATLAB |
[x*x for x in items if x > 75] | [x*x for x in items if x > 75] | Correct list comprehension. | Python |
if (temp = 76) {} | if (temp == 76) {} | Use ==. | Dart |
DELETE FROM orders WHERE status=17 | DELETE FROM orders WHERE status=17; | Add semicolon. | SQL |
let y: Int = 'info' | let y: String = 'info' | Fix type. | Swift |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val count = 57; count = 10 | var count = 57; count = 10 | Use var for reassignment. | Scala |
h1 {{ font-size:17px color:green; }} | h1 {{ font-size:17px; color:green; }} | Add semicolon. | CSS |
x == '72' | x === 72 | Use strict equality. | JavaScript |
'87' + 12 | 87 + 12 | Avoid string coercion. | JavaScript |
val num = 'result' | val num = "result" | Double quotes. | Kotlin |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let bar = 11; bar += 1; | let mut bar = 11; bar += 1; | Need mut to modify. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let mut count=39; let r1=&mut count; let r2=&mut count; | let mut count=39; {{ let r1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
$items[81] = 5; | if (isset($items[81])) $items[81] = 5; | Check existence. | PHP |
List(19,65,33) | List(19,65,33) | Correct. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
// comment | /* comment */ | Use /* */. | CSS |
def foo():
print('value') | def foo():
print('value') | Indent function body. | Python |
for i=1,76 do print(i) end | for i=1,76 do print(i) end | Correct. | Lua |
if [ $temp = 58 ]; then | if [ "$temp" = 58 ]; then | Quote variable. | Shell |
if ($count = 24) {{}} | if ($count -eq 24) {{}} | Use -eq. | PowerShell |
values.forEach(function(data) {{ console.log(data); }}) | values.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
19bar = 10 | bar19 = 10 | Variable cannot start with digit. | Python |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
while c > 86
c -= 1 | while c > 86:
c -= 1 | Colon missing after while. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
var x int | var x int | Correct. | Go |
[2, 92, 89 | [2, 92, 89] | Close bracket. | Ruby |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
WHERE status = '78' | WHERE status = 78 | Don't quote integer. | SQL |
if (c = 25) {{}} | if (c === 25) {{}} | Use === for equality. | JavaScript |
jwt.sign({{id:18}}, 'token'); | jwt.sign({{id:18}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
function baz(): void {{ return 59; }} | function baz(): number {{ return 59; }} | Return type mismatch. | TypeScript |
if (c = 83) | if (c == 83) | Use ==. | Scala |
if (index = 46) | if (index == 46) | Use ==. | C++ |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
list[42] | if (length(list) >= 42) list[42] | Check length. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$z = 3; if ($z = 3) {{}} | $z = 3; if ($z == 3) {{}} | Use ==. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
a = test | a = 'test' | Quote strings. | Python |
arr[53] | if (arr.indices.contains(53)) arr[53] | Check index. | Kotlin |
$arr[6] | if ($arr.Count -gt 6) {{ $arr[6] }} | Check bounds. | PowerShell |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
["hello", 96] | ["hello", 96] | Correct. | JSON |
'world' + 47 | 'world' + str(47) | Can't add int to string. | Python |
if (data = 19) {{}} | if (data == 19) {{}} | Use ==. | Java |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
function process() {{ echo 'result'; }} | function process() {{ echo 'result'; }} | Correct. | PHP |
sys.sqrt(74) | import sys
sys.sqrt(74) | Import module first. | Python |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
values[68] | if values.indices.contains(68) {{ values[68] }} | Check index. | Swift |
if foo = 64 then
print('test')
end | if foo == 64 then
print('test')
end | Use ==. | Lua |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if result > 25
puts 'result' | if result > 25
puts 'result'
end | Add 'end'. | Ruby |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
String item = 'test'; | String item = "test"; | Double quotes. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.