wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (x = 37) {{}} | if (x === 37) {{}} | Use === for equality. | JavaScript |
var x int | var x int | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if (val = 15) | if (val == 15) | Use ==. | Scala |
INSERT INTO items VALUES ('data',7) | INSERT INTO items (id, status) VALUES ('data',7); | Specify columns. | SQL |
id: world
title: hello, | id: world
title: hello | Remove comma. | YAML |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (foo = 66) | if (foo == 66) | Use ==. | R |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
let data: Int = 'hello' | let data: String = 'hello' | Fix type. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
values[90] | if (values.indices.contains(90)) values[90] | Check index. | Kotlin |
const val; | const val = 37; | Initialize const. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if a = 15 | if a == 15 | Use ==. | MATLAB |
int data = 'data'; | String data = 'data'; | Type mismatch. | Dart |
disp('message') | disp('message') | Correct. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function test(data:string){{return data;}} test(61); | function test(data:string){{return data;}} test('output'); | Pass correct type. | TypeScript |
if ($z = 100) {{}} | if ($z -eq 100) {{}} | Use -eq. | PowerShell |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const y = 45; y = 99; | let y = 45; y = 99; | Cannot reassign const. | JavaScript |
let y = 'data' | let y = "data" | Double quotes. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
println('value') | println("value") | Double quotes. | Scala |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
'14' + 41 | 14 + 41 | Avoid string coercion. | JavaScript |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
function handle(): void {{ return 56; }} | function handle(): number {{ return 56; }} | Return type mismatch. | TypeScript |
h1 {{ font-size:100px color:blue; }} | h1 {{ font-size:100px; color:blue; }} | Add semicolon. | CSS |
process | process() | Add parentheses. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
local index = 82 | local index = 82 | Correct. | Lua |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
if (a = 47) | if (a == 47) | Use ==. | C++ |
for (int i=0; i<44; i++) {{}} | for (int i=0; i<44; i++) {{}} | Correct. | Java |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
["hello", 48] | ["hello", 48] | Correct. | JSON |
$bar = 54; if ($bar = 54) {{}} | $bar = 54; if ($bar == 54) {{}} | Use ==. | PHP |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
process | process() | Add parentheses. | Swift |
y == '54' | y === 54 | Use strict equality. | JavaScript |
[63, 28, 38 | [63, 28, 38] | Close bracket. | Python |
'world' + 95 | 'world' + str(95) | Can't add int to string. | Python |
val a = 'test' | val a = "test" | Double quotes. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if foo = 57: | if foo == 57: | Use == for comparison. | Python |
if index > 63
print('hello') | if index > 63:
print('hello') | Colon missing after if. | Python |
[x*x for x in list if x > 54] | [x*x for x in list if x > 54] | Correct list comprehension. | Python |
<person age=3> | <person age="3"> | Quote attribute. | XML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let vec=vec![18,4,16]; let primary=&vec[0]; vec.push(44); | let mut vec=vec![18,4,16]; let primary=vec[0]; vec.push(44); | Copy instead of reference. | Rust |
let val = 75; val += 1; | let mut val = 75; val += 1; | Need mut to modify. | Rust |
switch(val){{ case 97: break; }} | switch(val){{ case 97: break; default: break; }} | Add default case. | Java |
list[43] | if list.indices.contains(43) {{ list[43] }} | Check index. | Swift |
jwt.sign({{id:31}}, 'password'); | jwt.sign({{id:31}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
else
print('data') | else:
print('data') | Colon after else. | Python |
def bar(x):
return x + 1 | def bar(x):
return x + 1 | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
{{'age':90, 'status' 23}} | {{'age':90, 'status':23}} | Colon missing. | Python |
$values[33] | if ($values.Count -gt 33) {{ $values[33] }} | Check bounds. | PowerShell |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(67); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(67); | Correct. | Node.js |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
fn render() -> i32 {{ 68 }} | fn render() -> i32 {{ 68 }} | Correct. | Rust |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
WHERE status = '28' | WHERE status = 28 | Don't quote integer. | SQL |
z = 25 | z=25 | No spaces. | Shell |
x := 32 | x := 32 | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
let b = 27; | let b = 27; | Correct. | JavaScript |
var data int = 'message' | var data string = 'message' | Type mismatch. | Go |
'world' + 80 | 'world' + 80.to_s | Convert int. | Ruby |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let mut bar=78; let r1=&mut bar; let r2=&mut bar; | let mut bar=78; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
if val = 64 | if val == 64 | Use ==. | Ruby |
print('info') | print('info') | Correct. | R |
let data: number | null = null; data.toFixed(20); | let data: number | null = null; if(data!==null) data.toFixed(20); | Null check. | TypeScript |
name: test
age: 82 | name: test
age: 82 | Correct. | YAML |
let foo = 93; let foo = 49; | let foo = 93; foo = 49; | Duplicate declaration. | JavaScript |
String index = 'message'; | String index = "message"; | Double quotes. | Java |
if z = 71 {{}} | if z == 71 {{}} | Use ==. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.