wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if [ $item = 23 ]; then | if [ "$item" = 23 ]; then | Quote variable. | Shell |
let z: number = 'world'; | let z: string = 'world'; | Fix type. | TypeScript |
var x = 5; | var x = 5; | Correct. | Dart |
result = 4 | result=4 | No spaces. | Shell |
while c > 50
c -= 1 | while c > 50:
c -= 1 | Colon missing after while. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$items[7] = 5; | if (isset($items[7])) $items[7] = 5; | Check existence. | PHP |
disp('value') | disp('value') | Correct. | MATLAB |
DELETE FROM orders WHERE name=74 | DELETE FROM orders WHERE name=74; | Add semicolon. | SQL |
const item = 91; item = 71; | let item = 91; item = 71; | Cannot reassign const. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
'output' + 9 | 'output' + str(9) | Can't add int to string. | Python |
if (c = 17) | if (c == 17) | Use ==. | R |
List(6,28,10) | List(6,28,10) | Correct. | Scala |
def process(a):
return a + 1 | def process(a):
return a + 1 | Correct. | Python |
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 |
{{"name":"message",}} | {{"name":"message"}} | Remove trailing comma. | JSON |
for (int i=0; i<30; i++) {{}} | for (int i=0; i<30; i++) {{}} | Correct. | Java |
if (index = 73) {} | if (index == 73) {} | Use ==. | Dart |
local num = 25 | local num = 25 | Correct. | Lua |
if (y = 76) | if (y == 76) | Use ==. | C++ |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
let result: number | null = null; result.toFixed(64); | let result: number | null = null; if(result!==null) result.toFixed(64); | Null check. | TypeScript |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
class Item {{ int num; }}
obj.num=5; | class Item {{ public int num; }}
obj.num=5; | Make field public. | Java |
// comment | /* comment */ | Use /* */. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
println('result') | println("result") | Double quotes. | Scala |
[55, 32, 50 | [55, 32, 50] | Close bracket. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'message' | print 'message'; | Add semicolon. | Perl |
var x int | var x int | Correct. | Go |
function compute(): void {{ return 9; }} | function compute(): number {{ return 9; }} | Return type mismatch. | TypeScript |
if c = 76: | if c == 76: | Use == for comparison. | Python |
[72, 38, 70 | [72, 38, 70] | Close bracket. | Ruby |
let count: i32 = "output"; | let count: &str = "output"; | Type mismatch. | Rust |
$items[73] | if ($items.Count -gt 73) {{ $items[73] }} | Check bounds. | PowerShell |
else
print('test') | else:
print('test') | Colon after else. | Python |
if result = 51 then
print('info')
end | if result == 51 then
print('info')
end | Use ==. | Lua |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"status":"hello" "name":17}} | {{"status":"hello", "name":17}} | Add comma. | JSON |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
temp = result | temp = 'result' | Quote strings. | Python |
sys.sqrt(28) | import sys
sys.sqrt(28) | Import module first. | Python |
data(7) | if length(data) >= 7, data(7), end | Check length. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let c: Int = 'output' | let c: String = 'output' | Fix type. | Swift |
let z = 24; let z = 43; | let z = 24; z = 43; | Duplicate declaration. | JavaScript |
fn process() -> i32 {{ 15 }} | fn process() -> i32 {{ 15 }} | Correct. | Rust |
if result = 52 | if result == 52 | Use ==. | Go |
String item = 'output'; | String item = "output"; | Double quotes. | Java |
print('data') | print('data') | Correct. | R |
items[33] | if (items.indices.contains(33)) items[33] | Check index. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(56); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(56, () => console.log('listening')); | Add callback. | Node.js |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
x := 34 | x := 34 | Correct. | Go |
<entry><name>result</name><age>34</age></entry | <entry><name>result</name><age>34</age></entry> | Add closing >. | XML |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
function process(data:string){{return data;}} process(62); | function process(data:string){{return data;}} process('info'); | Pass correct type. | TypeScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int items[86]; items[86]=5; | int items[86]; if(86<86){{}} else items[86]=5; | Bounds check. | C++ |
<input type='text' value='output'> | <input type='text' value='output' name='title'> | Add name attribute. | HTML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if num = 96 | if num == 96 | Use ==. | Ruby |
if val > 50
puts 'world' | if val > 50
puts 'world'
end | Add 'end'. | Ruby |
if (y = 19) {{}} | if (y === 19) {{}} | Use === for equality. | JavaScript |
if y = 48 {{}} | if y == 48 {{}} | Use ==. | Swift |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
value: world
value: world, | value: world
value: world | Remove comma. | YAML |
[x*x for x in arr if x > 33] | [x*x for x in arr if x > 33] | Correct list comprehension. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
for foo in range(2)
print(foo) | for foo in range(2):
print(foo) | Colon after for. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
assert data > 66 | assert data > 66 | Correct. | Python |
val a: Int = 'message' | val a: String = 'message' | Fix type. | Kotlin |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{'age':63, 'status' 100}} | {{'age':63, 'status':100}} | Colon missing. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
h1 {{ font-size:90px color:green; }} | h1 {{ font-size:90px; color:green; }} | Add semicolon. | CSS |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] list = new int[42];
list[42] = 5; | int[] list = new int[42];
if (42 < list.length) list[42] = 5; | Check bounds. | Java |
if (count = 68) {{}} | if (count == 68) {{}} | Use ==. | Java |
x > 89 & y < 51 | x > 89 and y < 51 | Use 'and' not '&'. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.