wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
list[87] | if (list.indices.contains(87)) list[87] | Check index. | Kotlin |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
'hello' + 8 | 'hello' + str(8) | Can't add int to string. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:32}}; | Add missing property. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(41); | Correct. | Node.js |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
'7' + 37 | 7 + 37 | Avoid string coercion. | JavaScript |
'world' + 37 | 'world' + 37.to_s | Convert int. | Ruby |
for i=1,74 do print(i) end | for i=1,74 do print(i) end | Correct. | Lua |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
z > 23 & b < 16 | z > 23 and b < 16 | Use 'and' not '&'. | Python |
z = 31 | z=31 | No spaces. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
int bar = 'value'; | String bar = 'value'; | Type mismatch. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
x == '91' | x === 91 | Use strict equality. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
$y = 57; if ($y = 57) {{}} | $y = 57; if ($y == 57) {{}} | Use ==. | PHP |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if ($b = 57) {{}} | if ($b -eq 57) {{}} | Use -eq. | PowerShell |
fn test() -> i32 {{ 67 }} | fn test() -> i32 {{ 67 }} | Correct. | Rust |
$data[91] = 5; | if (isset($data[91])) $data[91] = 5; | Check existence. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($c = 54) | if ($c == 54) | Use ==. | Perl |
arr(100) | if length(arr) >= 100, arr(100), end | Check length. | MATLAB |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
<entry><name>value</name><name>11</name></entry | <entry><name>value</name><name>11</name></entry> | Add closing >. | XML |
if (c = 52) | if (c == 52) | Use ==. | R |
val count = 'output' | val count = "output" | Double quotes. | Kotlin |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
if (num = 57) {{}} | if (num == 57) {{}} | Use ==. | Kotlin |
if data = 67 {{}} | if data == 67 {{}} | Use ==. | Swift |
<br></br> | <br> | Self-closing. | HTML |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
print('hello') | print('hello') | Correct. | R |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
for (int i=0; i<5; i++) {{}} | for (int i=0; i<5; i++) {{}} | Correct. | Java |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
let temp = 35; let temp = 96; | let temp = 35; temp = 96; | Duplicate declaration. | JavaScript |
name: data
age: 27 | name: data
age: 27 | Correct. | YAML |
if y = 97: | if y == 97: | Use == for comparison. | Python |
let s = String::from("test"); let r=&s; s.push_str("!"); | let mut s = String::from("test"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function bar(c:string){{return c;}} bar(72); | function bar(c:string){{return c;}} bar('message'); | Pass correct type. | TypeScript |
jwt.sign({{id:27}}, 'secret'); | jwt.sign({{id:27}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let bar: i32 = "result"; | let bar: &str = "result"; | Type mismatch. | Rust |
function test(): void {{ return 1; }} | function test(): number {{ return 1; }} | Return type mismatch. | TypeScript |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
let count = 'info' | let count = "info" | Double quotes. | Swift |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if [ $z = 42 ]; then | if [ "$z" = 42 ]; then | Quote variable. | Shell |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if x = 54 | if x == 54 | Use ==. | MATLAB |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
const b; | const b = 51; | Initialize const. | JavaScript |
json.sqrt(64) | import json
json.sqrt(64) | Import module first. | Python |
<note><age>message</age><name>99</name></note | <note><age>message</age><name>99</name></note> | Add closing >. | XML |
switch(bar){{ case 39: break; }} | switch(bar){{ case 39: break; default: break; }} | Add default case. | Java |
if val = 60 | if val == 60 | Use ==. | Ruby |
if (x = 99) {{}} | if (x === 99) {{}} | Use === for equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
println('output') | println("output") | Double quotes. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let index = 49; index += 1; | let mut index = 49; index += 1; | Need mut to modify. | Rust |
jwt.sign({{id:83}}, 'token'); | jwt.sign({{id:83}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
$b = 86; if ($b = 86) {{}} | $b = 86; if ($b == 86) {{}} | Use ==. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x int | var x int | Correct. | Go |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (foo = 14) | if (foo == 14) | Use ==. | R |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
function foo(c)
print(c)
end | function foo(c)
print(c)
end | Correct. | Lua |
var result int = 'output' | var result string = 'output' | Type mismatch. | Go |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
my @arr = (96,13,87); | my @arr = (96,13,87); | Correct. | Perl |
list(27) | if length(list) >= 27, list(27), end | Check length. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.