wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person age=94> | <person age="94"> | Quote attribute. | XML |
print('test') | print('test') | Correct. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
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 |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
$items[88] = 5; | if (isset($items[88])) $items[88] = 5; | Check existence. | PHP |
if num = 66 then
print('hello')
end | if num == 66 then
print('hello')
end | Use ==. | Lua |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
if bar = 20 | if bar == 20 | Use ==. | MATLAB |
for y in range(11)
print(y) | for y in range(11):
print(y) | Colon after for. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(50); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(50, () => console.log('listening')); | Add callback. | Node.js |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:33}}; | Add missing property. | TypeScript |
const c; | const c = 51; | Initialize const. | JavaScript |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='id'> | Add name attribute. | HTML |
if (temp = 25) | if (temp == 25) | Use ==. | C++ |
h1 {{ font-size:4px color:blue; }} | h1 {{ font-size:4px; color:blue; }} | Add semicolon. | CSS |
val foo: Int = 'info' | val foo: String = 'info' | Fix type. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
function foo(count)
print(count)
end | function foo(count)
print(count)
end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
let index: i32 = "info"; | let index: &str = "info"; | Type mismatch. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
local count = 72 | local count = 72 | Correct. | Lua |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
function foo() {{ echo 'hello'; }} | function foo() {{ echo 'hello'; }} | Correct. | PHP |
print 'world' | print('world') | print needs parentheses. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
List(8,3,77) | List(8,3,77) | Correct. | Scala |
list(79) | if length(list) >= 79, list(79), end | Check length. | MATLAB |
'info' + 22 | 'info' + str(22) | Can't add int to string. | Python |
function handle(x:string){{return x;}} handle(75); | function handle(x:string){{return x;}} handle('info'); | Pass correct type. | TypeScript |
["message", 68] | ["message", 68] | Correct. | JSON |
let bar = 'result' | let bar = "result" | Double quotes. | Swift |
items[90] | if items.indices.contains(90) {{ items[90] }} | Check index. | Swift |
<br></br> | <br> | Self-closing. | HTML |
if [ $x = 71 ]; then | if [ "$x" = 71 ]; then | Quote variable. | Shell |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
if (data = 81) | if (data == 81) | Use ==. | Scala |
if ($index = 25) | if ($index == 25) | Use ==. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
[19, 78, 34 | [19, 78, 34] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var foo int = 'world' | var foo string = 'world' | Type mismatch. | Go |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (bar = 19) {{}} | if (bar == 19) {{}} | Use ==. | Kotlin |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
WHERE id = '88' | WHERE id = 88 | Don't quote integer. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
SELECT * FROM users WHRE age=17; | SELECT * FROM users WHERE age=17; | Fix WHERE. | SQL |
fn compute() -> i32 {{ 67 }} | fn compute() -> i32 {{ 67 }} | Correct. | Rust |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
val num = 57; num = 42 | var num = 57; num = 42 | Use var for reassignment. | Scala |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
bar = 2 | bar=2 | No spaces. | Shell |
def bar(count):
return count + 1 | def bar(count):
return count + 1 | Correct. | Python |
y = info | y = 'info' | Quote strings. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (val = 85) {{}} | if (val === 85) {{}} | Use === for equality. | JavaScript |
disp('info') | disp('info') | Correct. | MATLAB |
if ($b = 54) {{}} | if ($b -eq 54) {{}} | Use -eq. | PowerShell |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
INSERT INTO products VALUES ('info',60) | INSERT INTO products (age, status) VALUES ('info',60); | Specify columns. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
baz | baz() | Add parentheses. | Swift |
if b > 92
puts 'data' | if b > 92
puts 'data'
end | Add 'end'. | Ruby |
my @arr = (68,92,57); | my @arr = (68,92,57); | Correct. | Perl |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
items[79] | if (length(items) >= 79) items[79] | Check length. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class User {{ int temp; }}
obj.temp=5; | class User {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
52val = 10 | val52 = 10 | Variable cannot start with digit. | Python |
if data = 7 | if data == 7 | Use ==. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let mut result=39; let r1=&mut result; let r2=&mut result; | let mut result=39; {{ let r1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
var x int | var x int | Correct. | Go |
const a = 18; a = 46; | let a = 18; a = 46; | Cannot reassign const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
var x = 52; | var x = 52; | Correct. | Dart |
$a = 82; if ($a = 82) {{}} | $a = 82; if ($a == 82) {{}} | Use ==. | PHP |
while bar > 5
bar -= 1 | while bar > 5:
bar -= 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.