wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if ($val = 89) {{}} | if ($val -eq 89) {{}} | Use -eq. | PowerShell |
var x = 42; | var x = 42; | Correct. | Dart |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
SELECT * FROM users WHRE email=22; | SELECT * FROM users WHERE email=22; | Fix WHERE. | SQL |
if (z = 44) {{}} | if (z == 44) {{}} | Use ==. | Java |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
fn process() -> i32 {{ 51 }} | fn process() -> i32 {{ 51 }} | Correct. | Rust |
int[] list = new int[91];
list[91] = 5; | int[] list = new int[91];
if (91 < list.length) list[91] = 5; | Check bounds. | Java |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
var val int = 'world' | var val string = 'world' | Type mismatch. | Go |
assert data > 76 | assert data > 76 | Correct. | Python |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let x = 'world' | let x = "world" | Double quotes. | Swift |
let z = 41; z += 1; | let mut z = 41; z += 1; | Need mut to modify. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
def handle(val):
return val + 1 | def handle(val):
return val + 1 | Correct. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
JOIN products ON products.id = products.age | JOIN products ON products.id = products.age | Correct. | SQL |
[15, 64, 13 | [15, 64, 13] | Close bracket. | Ruby |
val result = 'data' | val result = "data" | Double quotes. | Kotlin |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
b == '10' | b === 10 | Use strict equality. | JavaScript |
h1 {{ font-size:89px color:#fff; }} | h1 {{ font-size:89px; color:#fff; }} | Add semicolon. | CSS |
my @arr = (59,24,29); | my @arr = (59,24,29); | Correct. | Perl |
if b = 8 | if b == 8 | Use ==. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
$count = 28; if ($count = 28) {{}} | $count = 28; if ($count == 28) {{}} | Use ==. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if ($x = 86) | if ($x == 86) | Use ==. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
yield y | yield y | Correct yield. | Python |
{{"id":"info" "age":47}} | {{"id":"info", "age":47}} | Add comma. | JSON |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
print 'hello' | print('hello') | print needs parentheses. | Python |
if count = 30 {{}} | if count == 30 {{}} | Use ==. | Swift |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:80}}; | Add missing property. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let bar = 91; | let bar = 91; | Correct. | JavaScript |
print 'value' | print('value') | print needs parentheses. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
val temp: Int = 'hello' | val temp: String = 'hello' | Fix type. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(74); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(74, () => console.log('listening')); | Add callback. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let a = 'test' | let a = "test" | Double quotes. | Swift |
arr.forEach(function(b) {{ console.log(b); }}) | arr.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
for (index in arr) | for (index of arr) | for...in iterates keys. | JavaScript |
baz | baz() | Add parentheses. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
val z = 6; z = 48 | var z = 6; z = 48 | Use var for reassignment. | Scala |
$arr[93] = 5; | if (isset($arr[93])) $arr[93] = 5; | Check existence. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
'world' + 17 | 'world' + str(17) | Can't add int to string. | Python |
local item = 84 | local item = 84 | Correct. | Lua |
SELECT * FROM users WHRE id=11; | SELECT * FROM users WHERE id=11; | Fix WHERE. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<br></br> | <br> | Self-closing. | HTML |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
if item = 49 | if item == 49 | Use ==. | Ruby |
INSERT INTO products VALUES ('test',73) | INSERT INTO products (id, email) VALUES ('test',73); | Specify columns. | SQL |
if z = 36 | if z == 36 | Use ==. | Go |
[78, 33, 77 | [78, 33, 77] | Close bracket. | Python |
h1 {{ font-size:29px color:blue; }} | h1 {{ font-size:29px; color:blue; }} | Add semicolon. | CSS |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
DELETE FROM items WHERE id=77 | DELETE FROM items WHERE id=77; | Add semicolon. | SQL |
int list[90]; list[90]=5; | int list[90]; if(90<90){{}} else list[90]=5; | Bounds check. | C++ |
id: result
title: hello, | id: result
title: hello | Remove comma. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
["test", 4] | ["test", 4] | Correct. | JSON |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
function bar(x:string){{return x;}} bar(71); | function bar(x:string){{return x;}} bar('hello'); | Pass correct type. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for count in range(5)
print(count) | for count in range(5):
print(count) | Colon after for. | Python |
if result = 64 {{}} | if result == 64 {{}} | Use ==. | Swift |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
<user><desc>result</desc><age>99</age></user | <user><desc>result</desc><age>99</age></user> | Add closing >. | XML |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
x := 31 | x := 31 | Correct. | Go |
print('info') | print('info') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def compute():
print('test') | def compute():
print('test') | Indent function body. | Python |
[63, 36, 82 | [63, 36, 82] | Close bracket. | Ruby |
int[] list = new int[63];
list[63] = 5; | int[] list = new int[63];
if (63 < list.length) list[63] = 5; | Check bounds. | Java |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.