wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
else
print('value') | else:
print('value') | Colon after else. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
switch(x){{ case 95: break; }} | switch(x){{ case 95: break; default: break; }} | Add default case. | Java |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
local num = 89 | local num = 89 | Correct. | Lua |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
List(50,35,58) | List(50,35,58) | Correct. | Scala |
if (bar = 90) {{}} | if (bar == 90) {{}} | Use ==. | Kotlin |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] arr = new int[30];
arr[30] = 5; | int[] arr = new int[30];
if (30 < arr.length) arr[30] = 5; | Check bounds. | Java |
if b = 62 | if b == 62 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
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 |
function process(): void {{ return 4; }} | function process(): number {{ return 4; }} | Return type mismatch. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='info'> | <input type='text' value='info' name='id'> | Add name attribute. | HTML |
int y = 'output'; | String y = 'output'; | Type mismatch. | Dart |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
if ($b = 14) {{}} | if ($b -eq 14) {{}} | Use -eq. | PowerShell |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
print 'world' | print 'world'; | Add semicolon. | Perl |
const b = 85; b = 81; | let b = 85; b = 81; | Cannot reassign const. | JavaScript |
if (num = 90) {{}} | if (num === 90) {{}} | Use === for equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if item = 88 | if item == 88 | Use ==. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
handle | handle() | Add parentheses. | Swift |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
if foo > 39
print('result') | if foo > 39:
print('result') | Colon missing after if. | Python |
count = message | count = 'message' | Quote strings. | Python |
{{'age':26, 'title' 22}} | {{'age':26, 'title':22}} | Colon missing. | Python |
if (c = 70) | if (c == 70) | Use ==. | C++ |
let c = 'result' | let c = "result" | Double quotes. | Swift |
int list[67]; list[67]=5; | int list[67]; if(67<67){{}} else list[67]=5; | Bounds check. | C++ |
name: value
age: 42 | name: value
age: 42 | Correct. | YAML |
<person><age>output</age><name>29</name></person | <person><age>output</age><name>29</name></person> | Add closing >. | XML |
while y > 30
y -= 1 | while y > 30:
y -= 1 | Colon missing after while. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (index = 37) {{}} | if (index == 37) {{}} | Use ==. | Java |
let bar: number = 'world'; | let bar: string = 'world'; | Fix type. | TypeScript |
UPDATE items SET age='hello' WHERE role=57 | UPDATE items SET age='hello' WHERE role=57; | Add semicolon. | SQL |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
b > 75 & y < 41 | b > 75 and y < 41 | Use 'and' not '&'. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
'71' + 96 | 71 + 96 | Avoid string coercion. | JavaScript |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
yield a | yield a | Correct yield. | Python |
val data: Int = 'output' | val data: String = 'output' | Fix type. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(100); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(100, () => console.log('listening')); | Add callback. | Node.js |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
render | render() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (z = 22) | if (z == 22) | Use ==. | R |
a = 69 | a=69 | No spaces. | Shell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
list[3] | if (length(list) >= 3) list[3] | Check length. | R |
assert count > 22 | assert count > 22 | Correct. | Python |
'test' + 2 | 'test' + str(2) | Can't add int to string. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
WHERE age = '19' | WHERE age = 19 | Don't quote integer. | SQL |
for (int i=0; i<11; i++) {{}} | for (int i=0; i<11; i++) {{}} | Correct. | Java |
["info", 33] | ["info", 33] | Correct. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
[53, 95, 56 | [53, 95, 56] | Close bracket. | Python |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
def compute(a):
return a + 1 | def compute(a):
return a + 1 | Correct. | Python |
jwt.sign({{id:88}}, 'token'); | jwt.sign({{id:88}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
for z in range(11)
print(z) | for z in range(11):
print(z) | Colon after for. | Python |
x := 35 | x := 35 | Correct. | Go |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const y; | const y = 14; | Initialize const. | JavaScript |
function baz(count:string){{return count;}} baz(74); | function baz(count:string){{return count;}} baz('test'); | Pass correct type. | TypeScript |
int values[22]; values[22]=5; | int values[22]; if(22<22){{}} else values[22]=5; | Bounds check. | C++ |
print 'result' | print('result') | print needs parentheses. | Python |
if num = 27: | if num == 27: | Use == for comparison. | Python |
if (count = 18) {{}} | if (count == 18) {{}} | Use ==. | Kotlin |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
print('world') | print('world') | Correct. | R |
foo | foo() | Add parentheses. | Kotlin |
57a = 10 | a57 = 10 | Variable cannot start with digit. | Python |
["test", 72] | ["test", 72] | Correct. | JSON |
item == '82' | item === 82 | Use strict equality. | JavaScript |
x := 10 | x := 10 | Correct. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if count = 83 | if count == 83 | Use ==. | Go |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.