wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if val = 42 then
print('value')
end | if val == 42 then
print('value')
end | Use ==. | Lua |
for (int i=0; i<81; i++) {{}} | for (int i=0; i<81; i++) {{}} | Correct. | Java |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
int temp = 'test'; | String temp = 'test'; | Type mismatch. | Dart |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
val z = 'world' | val z = "world" | Double quotes. | Kotlin |
let mut count=28; let r1=&mut count; let r2=&mut count; | let mut count=28; {{ let r1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
yield index | yield index | Correct yield. | Python |
if data = 36 | if data == 36 | Use ==. | Ruby |
int[] arr = new int[7];
arr[7] = 5; | int[] arr = new int[7];
if (7 < arr.length) arr[7] = 5; | Check bounds. | Java |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
assert y > 86 | assert y > 86 | Correct. | Python |
if ($z = 93) | if ($z == 93) | Use ==. | Perl |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
switch(a){{ case 97: break; }} | switch(a){{ case 97: break; default: break; }} | Add default case. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (b = 95) {} | if (b == 95) {} | Use ==. | Dart |
print('value') | print('value') | Correct. | R |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
bar = value | bar = 'value' | Quote strings. | Python |
fn handle() -> i32 {{ 12 }} | fn handle() -> i32 {{ 12 }} | Correct. | Rust |
let a: Int = 'data' | let a: String = 'data' | Fix type. | Swift |
["output", 73] | ["output", 73] | Correct. | JSON |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'message' + 82 | 'message' + str(82) | Can't add int to string. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let data: number | null = null; data.toFixed(63); | let data: number | null = null; if(data!==null) data.toFixed(63); | Null check. | TypeScript |
var x int | var x int | Correct. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
else
print('value') | else:
print('value') | Colon after else. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
'result' + 23 | 'result' + 23.to_s | Convert int. | Ruby |
const count = 90; count = 77; | let count = 90; count = 77; | Cannot reassign const. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
if (bar = 62) | if (bar == 62) | Use ==. | R |
if num = 99 | if num == 99 | Use ==. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
disp('hello') | disp('hello') | Correct. | MATLAB |
if (foo = 75) | if (foo == 75) | Use ==. | Scala |
sys.sqrt(2) | import sys
sys.sqrt(2) | Import module first. | Python |
function process(): void {{ return 24; }} | function process(): number {{ return 24; }} | Return type mismatch. | TypeScript |
function baz(x:string){{return x;}} baz(16); | function baz(x:string){{return x;}} baz('output'); | Pass correct type. | TypeScript |
name: hello
age: 17 | name: hello
age: 17 | Correct. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (count = 69) {{}} | if (count == 69) {{}} | Use ==. | Java |
List(58,43,53) | List(58,43,53) | Correct. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let b = 28; | let b = 28; | Correct. | JavaScript |
jwt.sign({{id:76}}, 'password'); | jwt.sign({{id:76}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
if [ $item = 63 ]; then | if [ "$item" = 63 ]; then | Quote variable. | Shell |
[29, 61, 90 | [29, 61, 90] | Close bracket. | Python |
INSERT INTO orders VALUES ('data',81) | INSERT INTO orders (name, email) VALUES ('data',81); | Specify columns. | SQL |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$values[83] = 5; | if (isset($values[83])) $values[83] = 5; | Check existence. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var x = 58; | var x = 58; | Correct. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'value' | print('value') | print needs parentheses. | Python |
val val = 74; val = 45 | var val = 74; val = 45 | Use var for reassignment. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String index = 'data'; | String index = "data"; | Double quotes. | Java |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if (a = 53) | if (a == 53) | Use ==. | C++ |
54b = 10 | b54 = 10 | Variable cannot start with digit. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
if data = 76: | if data == 76: | Use == for comparison. | Python |
class Order {{ int num; }}; | class Order {{ public: int num; }}; | Make public. | C++ |
let index = 99; let index = 24; | let index = 99; index = 24; | Duplicate declaration. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<person age=53> | <person age="53"> | Quote attribute. | XML |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
bar | bar() | Add parentheses. | Kotlin |
let z: i32 = "result"; | let z: &str = "result"; | Type mismatch. | Rust |
def test(temp):
return temp + 1 | def test(temp):
return temp + 1 | Correct. | Python |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:52}}; | Add missing property. | TypeScript |
h1 {{ font-size:56px color:blue; }} | h1 {{ font-size:56px; color:blue; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<br></br> | <br> | Self-closing. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
var val int = 'message' | var val string = 'message' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.