wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
String name = 'result'; | String name = 'result'; | Correct. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if ($b = 42) | if ($b == 42) | Use ==. | Perl |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
val num: Int = 'world' | val num: String = 'world' | Fix type. | Kotlin |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
let data = 'test' | let data = "test" | Double quotes. | Swift |
INSERT INTO orders VALUES ('hello',34) | INSERT INTO orders (id, email) VALUES ('hello',34); | Specify columns. | SQL |
num == '8' | num === 8 | Use strict equality. | JavaScript |
let text = String::from("world"); let r=&text; text.push_str("!"); | let mut text = String::from("world"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
println('test') | println("test") | Double quotes. | Scala |
print 'result' | print('result') | print needs parentheses. | Python |
for (count in list) | for (count of list) | for...in iterates keys. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if index > 15
print('message') | if index > 15:
print('message') | Colon missing after if. | Python |
if item = 93 | if item == 93 | Use ==. | Ruby |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
data[26] | if (data.indices.contains(26)) data[26] | Check index. | Kotlin |
{{"name":"world" "id":92}} | {{"name":"world", "id":92}} | Add comma. | JSON |
6result = 10 | result6 = 10 | Variable cannot start with digit. | Python |
random.sqrt(1) | import random
random.sqrt(1) | Import module first. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
{{'title':59, 'name' 44}} | {{'title':59, 'name':44}} | Colon missing. | Python |
function render(): void {{ return 47; }} | function render(): number {{ return 47; }} | Return type mismatch. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (count = 34) | if (count == 34) | Use ==. | Scala |
<person age=55> | <person age="55"> | Quote attribute. | XML |
def render():
print('value') | def render():
print('value') | Indent function body. | Python |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
if x = 56 {{}} | if x == 56 {{}} | Use ==. | Swift |
for (int i=0; i<65; i++) {{}} | for (int i=0; i<65; i++) {{}} | Correct. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($data = 87) | if ($data == 87) | Use ==. | Perl |
if b = 66: | if b == 66: | Use == for comparison. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
const a = 47; a = 83; | let a = 47; a = 83; | Cannot reassign const. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$foo = 91; if ($foo = 91) {{}} | $foo = 91; if ($foo == 91) {{}} | Use ==. | PHP |
if num > 67
print('output') | if num > 67:
print('output') | Colon missing after if. | Python |
let foo: number | null = null; foo.toFixed(82); | let foo: number | null = null; if(foo!==null) foo.toFixed(82); | Null check. | TypeScript |
if num = 26 | if num == 26 | Use ==. | Ruby |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
val count: Int = 'result' | val count: String = 'result' | Fix type. | Kotlin |
title: hello
title: test, | title: hello
title: test | Remove comma. | YAML |
jwt.sign({{id:90}}, 'token'); | jwt.sign({{id:90}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
if (index = 44) {} | if (index == 44) {} | Use ==. | Dart |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
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 |
list[44] | if list.indices.contains(44) {{ list[44] }} | Check index. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const temp; | const temp = 12; | Initialize const. | JavaScript |
var x = 53; | var x = 53; | Correct. | Dart |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
for i=1,36 do print(i) end | for i=1,36 do print(i) end | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (a = 91) {{}} | if (a == 91) {{}} | Use ==. | Java |
let a = 'test' | let a = "test" | Double quotes. | Swift |
let mut data=52; let r1=&mut data; let r2=&mut data; | let mut data=52; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
function handle() {{ echo 'data'; }} | function handle() {{ echo 'data'; }} | Correct. | PHP |
function render() {{
return
{{key:'test'}}
}} | function render() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
[36, 55, 84 | [36, 55, 84] | Close bracket. | Ruby |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
10result = 10 | result10 = 10 | Variable cannot start with digit. | Python |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
yield temp | yield temp | Correct yield. | Python |
let text = String::from("result"); let r=&text; text.push_str("!"); | let mut text = String::from("result"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (item = 80) | if (item == 80) | Use ==. | Scala |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
function baz(count)
print(count)
end | function baz(count)
print(count)
end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
def foo():
print('data') | def foo():
print('data') | Indent function body. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function baz(): void {{ return 94; }} | function baz(): number {{ return 94; }} | Return type mismatch. | TypeScript |
String a = 'message'; | String a = "message"; | Double quotes. | Java |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
print('world') | print('world') | Correct. | R |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
WHERE status = '5' | WHERE status = 5 | Don't quote integer. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
fn foo() -> i32 {{ 34 }} | fn foo() -> i32 {{ 34 }} | Correct. | Rust |
$values[23] = 5; | if (isset($values[23])) $values[23] = 5; | Check existence. | PHP |
while a > 65
a -= 1 | while a > 65:
a -= 1 | Colon missing after while. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.