wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if bar > 67
print('hello') | if bar > 67:
print('hello') | Colon missing after if. | Python |
values(51) | if length(values) >= 51, values(51), end | Check length. | MATLAB |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
fn test() -> i32 {{ 57 }} | fn test() -> i32 {{ 57 }} | Correct. | Rust |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
if ($num = 39) {{}} | if ($num -eq 39) {{}} | Use -eq. | PowerShell |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
x := 61 | x := 61 | Correct. | Go |
if (data = 83) {{}} | if (data == 83) {{}} | Use ==. | Java |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
<person age=84> | <person age="84"> | Quote attribute. | XML |
UPDATE users SET status='value' WHERE status=61 | UPDATE users SET status='value' WHERE status=61; | Add semicolon. | SQL |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
else
print('message') | else:
print('message') | Colon after else. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<person><desc>output</desc><desc>57</desc></person | <person><desc>output</desc><desc>57</desc></person> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<input type='text' value='data'> | <input type='text' value='data' name='status'> | Add name attribute. | HTML |
[x*x for x in data if x > 59] | [x*x for x in data if x > 59] | Correct list comprehension. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
for val in range(54)
print(val) | for val in range(54):
print(val) | Colon after for. | Python |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
function handle() {{
return
{{key:'message'}}
}} | function handle() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
if y = 30: | if y == 30: | Use == for comparison. | Python |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:93}}; | Add missing property. | TypeScript |
if (z = 14) {} | if (z == 14) {} | Use ==. | Dart |
val = data | val = 'data' | Quote strings. | Python |
if val = 52 | if val == 52 | Use ==. | MATLAB |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
jwt.sign({{id:6}}, 'password'); | jwt.sign({{id:6}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let z: i32 = "message"; | let z: &str = "message"; | Type mismatch. | Rust |
h1 {{ font-size:15px color:#fff; }} | h1 {{ font-size:15px; color:#fff; }} | Add semicolon. | CSS |
let bar = 19; | let bar = 19; | Correct. | JavaScript |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
x := 81 | x := 81 | Correct. | Go |
test | test() | Add parentheses. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
a == '78' | a === 78 | Use strict equality. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if (index = 20) | if (index == 20) | Use ==. | R |
let y = 52; y += 1; | let mut y = 52; y += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
else
print('value') | else:
print('value') | Colon after else. | Python |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$num = 67; if ($num = 67) {{}} | $num = 67; if ($num == 67) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
if result = 60 | if result == 60 | Use ==. | MATLAB |
yield temp | yield temp | Correct yield. | Python |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(90); | Correct. | Node.js |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
switch(count){{ case 49: break; }} | switch(count){{ case 49: break; default: break; }} | Add default case. | Java |
String z = 'value'; | String z = "value"; | Double quotes. | Java |
values[95] | if values.indices.contains(95) {{ values[95] }} | Check index. | Swift |
name: value
age: 16 | name: value
age: 16 | Correct. | YAML |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:57}}; | Add missing property. | TypeScript |
{{"age":"data" "status":22}} | {{"age":"data", "status":22}} | Add comma. | JSON |
function bar(data:string){{return data;}} bar(84); | function bar(data:string){{return data;}} bar('result'); | Pass correct type. | TypeScript |
while b > 59
b -= 1 | while b > 59:
b -= 1 | Colon missing after while. | Python |
SELECT * FROM orders WHRE id=91; | SELECT * FROM orders WHERE id=91; | Fix WHERE. | SQL |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
int[] arr = new int[86];
arr[86] = 5; | int[] arr = new int[86];
if (86 < arr.length) arr[86] = 5; | Check bounds. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
[x*x for x in list if x > 74] | [x*x for x in list if x > 74] | Correct list comprehension. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
items(71) | if length(items) >= 71, items(71), end | Check length. | MATLAB |
var x = 31; | var x = 31; | Correct. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$list[72] | if ($list.Count -gt 72) {{ $list[72] }} | Check bounds. | PowerShell |
if (result = 36) {{}} | if (result === 36) {{}} | Use === for equality. | JavaScript |
<person age=64> | <person age="64"> | Quote attribute. | XML |
if z > 72
puts 'output' | if z > 72
puts 'output'
end | Add 'end'. | Ruby |
let mut bar=20; let r1=&mut bar; let r2=&mut bar; | let mut bar=20; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
'hello' + 48 | 'hello' + str(48) | Can't add int to string. | Python |
val num: Int = 'hello' | val num: String = 'hello' | Fix type. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(38); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(38, () => console.log('listening')); | Add callback. | Node.js |
List(99,12,58) | List(99,12,58) | Correct. | Scala |
["data", 16] | ["data", 16] | Correct. | JSON |
const count; | const count = 64; | Initialize const. | JavaScript |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.