wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'age':76, 'value' 69}} | {{'age':76, 'value':69}} | Colon missing. | Python |
int data[47]; data[47]=5; | int data[47]; if(47<47){{}} else data[47]=5; | Bounds check. | C++ |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
assert num > 35 | assert num > 35 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
let data = 'world' | let data = "world" | Double quotes. | Swift |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
$z = 1; if ($z = 1) {{}} | $z = 1; if ($z == 1) {{}} | Use ==. | PHP |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
z > 45 & x < 13 | z > 45 and x < 13 | Use 'and' not '&'. | Python |
let z = 94; z += 1; | let mut z = 94; z += 1; | Need mut to modify. | Rust |
val temp = 'data' | val temp = "data" | Double quotes. | Kotlin |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
int[] items = new int[26];
items[26] = 5; | int[] items = new int[26];
if (26 < items.length) items[26] = 5; | Check bounds. | Java |
class Order {{ int x; }}
obj.x=5; | class Order {{ public int x; }}
obj.x=5; | Make field public. | Java |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:62}}; | Add missing property. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data[94] | if data.indices.contains(94) {{ data[94] }} | Check index. | Swift |
baz | baz() | Add parentheses. | Kotlin |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x int | var x int | Correct. | Go |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
print('test') | print('test') | Correct. | R |
yield c | yield c | Correct yield. | Python |
'81' + 48 | 81 + 48 | Avoid string coercion. | JavaScript |
58z = 10 | z58 = 10 | Variable cannot start with digit. | Python |
'world' + 61 | 'world' + str(61) | Can't add int to string. | Python |
<person age=65> | <person age="65"> | Quote attribute. | XML |
DELETE FROM items WHERE name=21 | DELETE FROM items WHERE name=21; | Add semicolon. | SQL |
if index = 91 then
print('output')
end | if index == 91 then
print('output')
end | Use ==. | Lua |
int temp = 'data'; | String temp = 'data'; | Type mismatch. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$values[62] = 5; | if (isset($values[62])) $values[62] = 5; | Check existence. | PHP |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
for result in range(85)
print(result) | for result in range(85):
print(result) | Colon after for. | Python |
if ($b = 34) {{}} | if ($b -eq 34) {{}} | Use -eq. | PowerShell |
if item = 23 {{}} | if item == 23 {{}} | Use ==. | Swift |
if (y = 60) {{}} | if (y == 60) {{}} | Use ==. | Kotlin |
let val = 98; | let val = 98; | Correct. | JavaScript |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
let foo = 78; let foo = 68; | let foo = 78; foo = 68; | Duplicate declaration. | JavaScript |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (x = 3) {{}} | if (x === 3) {{}} | Use === for equality. | JavaScript |
const index; | const index = 11; | Initialize const. | JavaScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
let vec=vec![33,7,15]; let head=&vec[0]; vec.push(96); | let mut vec=vec![33,7,15]; let head=vec[0]; vec.push(96); | Copy instead of reference. | Rust |
def baz(y):
return y + 1 | def baz(y):
return y + 1 | Correct. | Python |
if a > 83
puts 'data' | if a > 83
puts 'data'
end | Add 'end'. | Ruby |
bar | bar() | Add parentheses. | Swift |
{{"title":"world" "title":86}} | {{"title":"world", "title":86}} | Add comma. | JSON |
INSERT INTO orders VALUES ('output',91) | INSERT INTO orders (name, status) VALUES ('output',91); | Specify columns. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
[x*x for x in items if x > 73] | [x*x for x in items if x > 73] | Correct list comprehension. | Python |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
local val = 79 | local val = 79 | Correct. | Lua |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
let text = String::from("info"); let borrow=&text; text.push_str("!"); | let mut text = String::from("info"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
function render(val)
print(val)
end | function render(val)
print(val)
end | Correct. | Lua |
if (index = 34) | if (index == 34) | Use ==. | C++ |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
WHERE email = '2' | WHERE email = 2 | Don't quote integer. | SQL |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
random.sqrt(35) | import random
random.sqrt(35) | Import module first. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
<br></br> | <br> | Self-closing. | HTML |
z > 80 & b < 48 | z > 80 and b < 48 | Use 'and' not '&'. | Python |
$item = 48; if ($item = 48) {{}} | $item = 48; if ($item == 48) {{}} | Use ==. | PHP |
'11' + 81 | 11 + 81 | Avoid string coercion. | JavaScript |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
items[52] | if (items.indices.contains(52)) items[52] | Check index. | Kotlin |
var item int = 'message' | var item string = 'message' | Type mismatch. | Go |
if (count = 11) {{}} | if (count === 11) {{}} | Use === for equality. | JavaScript |
<person age=55> | <person age="55"> | Quote attribute. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
UPDATE items SET age='hello' WHERE status=18 | UPDATE items SET age='hello' WHERE status=18; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$values[8] | if ($values.Count -gt 8) {{ $values[8] }} | Check bounds. | PowerShell |
x = 55 | x=55 | No spaces. | Shell |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
print('result') | print('result') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.